Skip to content

Commit

Permalink
feat: init nut-exporter image 🌰📤
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Apr 6, 2024
0 parents commit 60fd87c
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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): "
43 changes: 43 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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-exporter
name: nut-exporter
display-name: RaBe NUT Exporter
tags: minimal rhel9 ubi9 nut nut-exporter
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' }}
12 changes: 12 additions & 0 deletions .github/workflows/schedule.yaml
Original file line number Diff line number Diff line change
@@ -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-exporter:latest'
13 changes: 13 additions & 0 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM docker.io/hon95/prometheus-nut-exporter:1.2.1 as upstream
FROM ghcr.io/radiorabe/ubi9-minimal:0.6.6

COPY --from=upstream /app/prometheus-nut-exporter /usr/local/bin/prometheus-nut-exporter

ENV TZ=Europe/Zurich \
HTTP_PATH=/metrics \
HTTP_PORT='9614'

RUN microdnf install -y \
shadow-utils \
&& microdnf clean all \
&& useradd -u 1001 -r -g 0 -s /sbin/nologin \
-c "Default Application User" default \
&& microdnf remove -y \
libsemanage \
shadow-utils

USER 1001
EXPOSE 9614
ENTRYPOINT /usr/local/bin/prometheus-nut-exporter
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# RaBe NUT exporter Image

Container image with [prometheus-nut-exporter](https://github.com/HON95/prometheus-nut-exporter) for use with the [RaBe NUT Image](https://github.com/radiorabe/container-image-nut).

## Usage

Run it where your Prometheus can reach it and it can reach any NUT servers.

## 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:

```
<type>[optional scope]: <description>
[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/).
20 changes: 20 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: nut-exporter
description: Prometheus Exporter for NUT
annotations:
backstage.io/techdocs-ref: dir:.
github.com/project-slug: radiorabe/container-image-nut-exporter
links:
- url: https://wiki.rabe.ch/Network_UPS_Tools
title: RaBe Wiki Documentation
- url: https://github.com/HON95/prometheus-nut-exporter
title: Upstreeam Project
spec:
type: container
lifecycle: experimental
owner: it-reaktion
dependsOn:
- component:default/rabe-ubi9-minimal
10 changes: 10 additions & 0 deletions docs/css/style.css
Original file line number Diff line number Diff line change
@@ -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;
}
13 changes: 13 additions & 0 deletions docs/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -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").open("r") as readme, mkdocs_gen_files.open(
"index.md", "w", encoding="utf-8"
) as index_file:
index_file.writelines(readme.read())
49 changes: 49 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
site_name: RaBe NUT Exporter IMage
repo_url: https://github.com/radiorabe/container-image-nut-exporter
repo_name: radiorabe/container-image-nut-exporter

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

0 comments on commit 60fd87c

Please sign in to comment.