diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b3c7efd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: docker + directory: / + schedule: + interval: daily + commit-message: + prefix: "chore: " + groups: + baseimages: + patterns: + - "*" + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + commit-message: + prefix: "chore(ci): " diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ce3d348 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +name: Release + + +on: + pull_request: + push: + branches: + - main + tags: + - '*' + +jobs: + release-container: + uses: radiorabe/actions/.github/workflows/release-container.yaml@v0.20.8 + with: + image: ghcr.io/radiorabe/nut + name: nut + display-name: RaBe Network UPS Tools + tags: minimal rhel9 ubi9 nut + cosign-verify: true + mkdocs: + runs-on: ubuntu-latest + permissions: + actions: none + checks: none + contents: write # for pushing gh-pages branch + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + id-token: none + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: pip install mkdocs mkdocs-material mkdocs-gen-files mkdocs-literate-nav mkdocs-section-index + - run: mkdocs build + - run: mkdocs gh-deploy + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/schedule.yaml b/.github/workflows/schedule.yaml new file mode 100644 index 0000000..8232d20 --- /dev/null +++ b/.github/workflows/schedule.yaml @@ -0,0 +1,12 @@ +name: Scheduled tasks + +on: + schedule: + - cron: '13 12 * * *' + workflow_dispatch: + +jobs: + schedule-trivy: + uses: radiorabe/actions/.github/workflows/schedule-trivy.yaml@v0.20.8 + with: + image-ref: 'ghcr.io/radiorabe/nut:latest' diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml new file mode 100644 index 0000000..9917489 --- /dev/null +++ b/.github/workflows/semantic-release.yaml @@ -0,0 +1,13 @@ +name: Semantic Release + +on: + push: + branches: + - main + - release/* + +jobs: + semantic-release: + uses: radiorabe/actions/.github/workflows/semantic-release.yaml@v0.20.8 + secrets: + RABE_ITREAKTION_GITHUB_TOKEN: ${{ secrets.RABE_ITREAKTION_GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f3f150d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/radiorabe/ubi9-minimal:0.6.6 + +RUN microdnf install -y epel-release \ + && microdnf install -y \ + nut \ + shadow-utils \ + && microdnf clean all \ + && microdnf remove -y \ + libsemanage \ + shadow-utils \ + && mkdir /var/run/{nut,upsmon} \ + && chown nut /var/run/{nut,upsmon} \ + && chmod o-rwx /var/run/{nut,upsmon} \ + && chmod a-s \ + /usr/bin/* \ + /usr/sbin/* \ + /usr/libexec/*/* + +COPY entrypoint.sh /usr/local/bin/ + +USER 57 +EXPOSE 3493 +ENTRYPOINT /usr/local/bin/entrypoint.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a53c53 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# RaBe NUT Image + +[Network UPS Tools](https://networkupstools.org/) container image based on [RaBe UBI9 Minimal](https://github.com/radiorabe/container-image-ubi9-minimal). + +## Usage + +Run it as you please. Not that this image does not generate any automated configuration. + +## Release Management + +The CI/CD setup uses semantic commit messages following the [conventional commits standard](https://www.conventionalcommits.org/en/v1.0.0/). +The workflow is based on the [RaBe shared actions](https://radiorabe.github.io/actions/) +and uses [go-semantic-commit](https://go-semantic-release.xyz/) +to create new releases. + +The commit message should be structured as follows: + +``` +[optional scope]: + +[optional body] + +[optional footer(s)] +``` + +The commit contains the following structural elements, to communicate intent to the consumers of your library: + +1. **fix:** a commit of the type `fix` patches gets released with a PATCH version bump +1. **feat:** a commit of the type `feat` gets released as a MINOR version bump +1. **BREAKING CHANGE:** a commit that has a footer `BREAKING CHANGE:` gets released as a MAJOR version bump +1. types other than `fix:` and `feat:` are allowed and don't trigger a release + +If a commit does not contain a conventional commit style message you can fix +it during the squash and merge operation on the PR. + +## Build Process + +The CI/CD setup uses [Docker build-push Action](https://github.com/docker/build-push-action) + to publish container images. The workflow is based on the [RaBe shared actions](https://radiorabe.github.io/actions/). diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..e8e2991 --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: nut + description: Netowrk UPS Tools on UBI9 + annotations: + backstage.io/techdocs-ref: dir:. + github.com/project-slug: radiorabe/container-image-nut + links: + - url: https://networkupstools.org/ + title: Network UPS Tools Homepage +spec: + type: container + lifecycle: experimental + owner: it-reaktion + dependsOn: + - component:default/rabe-ubi9-minimal diff --git a/docs/css/style.css b/docs/css/style.css new file mode 100644 index 0000000..18a4c32 --- /dev/null +++ b/docs/css/style.css @@ -0,0 +1,10 @@ +/* set primary color */ +:root { + --md-primary-fg-color: #00C9BF; + --md-accent-fg-color: #00C9BF; +} + +/* make code selectable on main */ +.highlight .o { + user-select: none; +} diff --git a/docs/gen_ref_pages.py b/docs/gen_ref_pages.py new file mode 100644 index 0000000..d7bdecf --- /dev/null +++ b/docs/gen_ref_pages.py @@ -0,0 +1,13 @@ +"""Generate the code reference pages and navigation. + +From https://mkdocstrings.github.io/recipes/ +""" + +from pathlib import Path + +import mkdocs_gen_files + +with Path("README.md") as readme, mkdocs_gen_files.open( + "index.md", "w", encoding="utf-8" +) as index_file: + index_file.writelines(readme.read()) diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..15f19d2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#! /bin/bash -e + +readonly USER=nut +readonly GROUP=nut + +set -xe + +/sbin/upsdrvctl -u root start +/sbin/upsd +ls -al /run/nut +ls -al /var/run/nut +exec /sbin/upsmon -F diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..b5fb3e7 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,49 @@ +site_name: RaBe Network UPS Tools Container +repo_url: https://github.com/radiorabe/container-image-nut +repo_name: radiorabe/container-image-nut + +theme: + name: "material" + palette: + # Palette toggle for dark mode + - scheme: slate + primary: '#00c9bf' + toggle: + icon: material/brightness-4 + name: Switch to light mode + # Palette toggle for light mode + - scheme: default + primary: '#00c9bf' + toggle: + icon: material/brightness-7 + name: Switch to dark mode + icon: + repo: fontawesome/brands/git-alt + features: + - content.code.copy + - content.code.annotate + - toc.integrate + +markdown_extensions: +- pymdownx.highlight: + anchor_linenums: true +- pymdownx.inlinehilite +- pymdownx.snippets +- pymdownx.superfences + +extra_css: +- css/style.css + +plugins: +- search +- gen-files: + scripts: + - docs/gen_ref_pages.py +- literate-nav +- section-index + +nav: + - README: index.md + +watch: + - README.md