From 46e0a7052121b4e008d19d8f1312a6b444c5e892 Mon Sep 17 00:00:00 2001 From: dresi Date: Wed, 10 Jun 2026 10:29:16 +0200 Subject: [PATCH] feat: initial structure with rsyncd and telegraf-snmp images --- .gitea/workflows/rsyncd.yaml | 57 +++++++++++++++++++++++++++++ .gitea/workflows/telegraf-snmp.yaml | 57 +++++++++++++++++++++++++++++ rsyncd/Dockerfile | 14 +++++++ rsyncd/run.sh | 29 +++++++++++++++ telegraf-snmp/Dockerfile | 15 ++++++++ 5 files changed, 172 insertions(+) create mode 100644 .gitea/workflows/rsyncd.yaml create mode 100644 .gitea/workflows/telegraf-snmp.yaml create mode 100644 rsyncd/Dockerfile create mode 100644 rsyncd/run.sh create mode 100644 telegraf-snmp/Dockerfile diff --git a/.gitea/workflows/rsyncd.yaml b/.gitea/workflows/rsyncd.yaml new file mode 100644 index 0000000..c240f26 --- /dev/null +++ b/.gitea/workflows/rsyncd.yaml @@ -0,0 +1,57 @@ +name: Build and push rsyncd image +run-name: ${{ gitea.actor }} is building and pushing rsyncd image +on: + push: + paths: + - 'rsyncd/**' + - '.gitea/workflows/rsyncd.yaml' + +env: + RESULT_IMAGE_NAME: tools/rsyncd + +jobs: + build-and-push-image: + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Log in to registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.PRIVATE_REGISTRY_DOMAIN }} + username: ${{ secrets.PRIVATE_REGISTRY_USER }} + password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Prepare BuildKit config with custom CA + run: | + CONFIG_DIR_PATH="${{ runner.temp }}/buildx-config" + mkdir -p "${CONFIG_DIR_PATH}" + + CERT_FILE_PATH="${CONFIG_DIR_PATH}/ca.crt" + CONFIG_FILE_PATH="${CONFIG_DIR_PATH}/buildkitd.toml" + + echo "${{ vars.PRIVATE_REGISTRY_CA_CERT }}" > "${CERT_FILE_PATH}" + + cat << EOF > "${CONFIG_FILE_PATH}" + [registry."${{ vars.PRIVATE_REGISTRY_DOMAIN }}"] + ca = ["${CERT_FILE_PATH}"] + EOF + + echo "BUILDKIT_CONFIG=${CONFIG_FILE_PATH}" >> $GITEA_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config: ${{ env.BUILDKIT_CONFIG }} + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: rsyncd + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ vars.PRIVATE_REGISTRY_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:latest diff --git a/.gitea/workflows/telegraf-snmp.yaml b/.gitea/workflows/telegraf-snmp.yaml new file mode 100644 index 0000000..c934eaa --- /dev/null +++ b/.gitea/workflows/telegraf-snmp.yaml @@ -0,0 +1,57 @@ +name: Build and push telegraf-snmp image +run-name: ${{ gitea.actor }} is building and pushing telegraf-snmp image +on: + push: + paths: + - 'telegraf-snmp/**' + - '.gitea/workflows/telegraf-snmp.yaml' + +env: + RESULT_IMAGE_NAME: tools/telegraf-snmp + +jobs: + build-and-push-image: + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Log in to registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.PRIVATE_REGISTRY_DOMAIN }} + username: ${{ secrets.PRIVATE_REGISTRY_USER }} + password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Prepare BuildKit config with custom CA + run: | + CONFIG_DIR_PATH="${{ runner.temp }}/buildx-config" + mkdir -p "${CONFIG_DIR_PATH}" + + CERT_FILE_PATH="${CONFIG_DIR_PATH}/ca.crt" + CONFIG_FILE_PATH="${CONFIG_DIR_PATH}/buildkitd.toml" + + echo "${{ vars.PRIVATE_REGISTRY_CA_CERT }}" > "${CERT_FILE_PATH}" + + cat << EOF > "${CONFIG_FILE_PATH}" + [registry."${{ vars.PRIVATE_REGISTRY_DOMAIN }}"] + ca = ["${CERT_FILE_PATH}"] + EOF + + echo "BUILDKIT_CONFIG=${CONFIG_FILE_PATH}" >> $GITEA_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config: ${{ env.BUILDKIT_CONFIG }} + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: telegraf-snmp + platforms: linux/amd64 + push: true + tags: ${{ vars.PRIVATE_REGISTRY_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:latest diff --git a/rsyncd/Dockerfile b/rsyncd/Dockerfile new file mode 100644 index 0000000..d2581ef --- /dev/null +++ b/rsyncd/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:24.04 +LABEL org.opencontainers.image.authors="dockerimage@dresi.wtf" + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends rsync && \ + apt-get clean autoclean && \ + apt-get autoremove -y && \ + rm -rf /var/lib/{apt,dpkg,cache,log}/ + +EXPOSE 873 +VOLUME /volume +ADD ./run.sh /usr/local/bin/run.sh +RUN chmod +x /usr/local/bin/run.sh +ENTRYPOINT ["/usr/local/bin/run.sh"] diff --git a/rsyncd/run.sh b/rsyncd/run.sh new file mode 100644 index 0000000..4467fb1 --- /dev/null +++ b/rsyncd/run.sh @@ -0,0 +1,29 @@ +#!/bin/bash +VOLUME=${VOLUME:-"volume"} +ALLOW=${ALLOW:-192.168.0.0/16 172.16.0.0/12} +OWNER=${OWNER:-nobody} +GROUP=${GROUP:-nogroup} + +# create users matching ids passed if necessary +if [ "${GROUP}" != "nogroup" ]; then + groupadd -g ${GROUP} rsyncdgroup +fi +if [ "${OWNER}" != "nobody" ]; then + groupadd -u ${OWNER} -G rsyncdgroup rsyncduser +fi + +[ -f /etc/rsyncd.conf ] || cat < /etc/rsyncd.conf +uid = ${OWNER} +gid = ${GROUP} +use chroot = yes +pid file = /var/run/rsyncd.pid +log file = /dev/stdout +[${VOLUME}] + hosts deny = * + hosts allow = ${ALLOW} + read only = false + path = /volume + comment = ${VOLUME} +EOF + +exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf "$@" diff --git a/telegraf-snmp/Dockerfile b/telegraf-snmp/Dockerfile new file mode 100644 index 0000000..42493f4 --- /dev/null +++ b/telegraf-snmp/Dockerfile @@ -0,0 +1,15 @@ +FROM telegraf:latest +LABEL org.opencontainers.image.authors="dockerimage@dresi.wtf" + +RUN apt-get update && \ + apt-get install -y --no-install-recommends snmp-mibs-downloader wget && \ + download-mibs 2>/dev/null || true && \ + wget -q -O /usr/share/snmp/mibs/UBNT-MIB \ + https://raw.githubusercontent.com/librenms/librenms/master/mibs/ubiquiti/UBNT-MIB && \ + wget -q -O /usr/share/snmp/mibs/UBNT-UniFi-MIB \ + https://raw.githubusercontent.com/librenms/librenms/master/mibs/ubiquiti/UBNT-UniFi-MIB && \ + echo "mibs +ALL" >> /etc/snmp/snmp.conf && \ + apt-get remove -y wget && \ + apt-get clean autoclean && \ + apt-get autoremove -y && \ + rm -rf /var/lib/{apt,dpkg,cache,log}/