Add Container image and github actions (#1)

* add github workflow and dockerfile

* fix dockerfile path

* document docker usage in README

* remove environment
This commit is contained in:
Laura Batalha
2025-05-29 17:19:01 +01:00
committed by GitHub
parent 967579930a
commit 0e4f31e7dc
5 changed files with 184 additions and 1 deletions

View File

@@ -0,0 +1,135 @@
name: Build RNMon Container Images
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/rnmon
on:
push:
branches:
- '*'
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- master
paths-ignore:
- .gitignore
- LICENSE
- '*.example'
- '**.example'
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-containers-release:
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
- linux/arm/v6
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: .artifacts
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY_IMAGE }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
container-manifest-merge:
runs-on: ubuntu-latest
permissions:
packages: write
needs:
- build-containers-release
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

28
Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
ARG python_version=3.13
FROM python:${python_version}-alpine AS build
RUN apk add --no-cache build-base linux-headers libffi-dev libressl-dev cargo uv
ENV UV_TOOL_DIR=/app
RUN uv tool install --compile-bytecode rnmon
FROM python:${python_version}-alpine
ARG python_version
# Only copy the necessary files from the build stage, to improve layer efficiency
COPY --from=build /app/rnmon /app
RUN mkdir /config
RUN addgroup -S app --gid 1000 && adduser -S app --uid 1000 -G app
RUN chown -R app:app /config /app
USER app:app
VOLUME ["/config"]
ENV PYTHONUNBUFFERED=1
WORKDIR /app/bin
ENTRYPOINT ["./python", "rnmon", "--rns-config", "/config/reticulum", "--config", "/config/scraping.yaml"]

View File

View File

@@ -9,7 +9,9 @@ RNMon is a simple monitoring daemon designed to monitor the status of multiple R
## Installing
The package is available in [PyPI](https://pypi.org/project/rnmon/), install it with your python package manager of choice
### Package
The package is available in [PyPI](https://pypi.org/project/rnmon/), install it with your python package manager of choice.
I recommend using [`uv`](https://docs.astral.sh/uv/) since it cleanly manages an environment if you run or install it as a tool:
@@ -17,6 +19,17 @@ Execute it simply: `uvx rnmon`
Install it globally (but in its own environment): `uv tool install rnmon` and run `rnmon`
### Container
There is a container image available at `ghcr.io/lbataha/rnmon`.
You can use the `latest` tag, or specify the version matching the git tag you want, there are also image builds available in github actions.
The repo contains a `Dockerfile` and an example `docker-compose.yml`, but you can run it simply with:
```shell
docker run --name rnmon -v /path/to/config:/config ghcr.io/lbataha/rnmon:latest
```
## Configuration
Configure the daemon via `scraping.yaml`, the example config has comments explaining the options.

7
docker-compose.yaml Normal file
View File

@@ -0,0 +1,7 @@
services:
rnmon:
container_name: rnmon
image: ghcr.io/lbatalha/rnmon:latest
restart: unless-stopped
volumes:
- ./config:/config:rw