From 98e6dc77ee4378e60656aa5e5377a7d56125698b Mon Sep 17 00:00:00 2001 From: pi-farm Date: Tue, 24 Feb 2026 17:10:16 +0100 Subject: [PATCH] add default configs and s6-overlay --- Dockerfile | 35 +++++++---------- Dockerfile.aarch64 | 35 +++++++---------- buildargs.env | 39 +++++++++---------- root/defaults/alpine-mirror | 21 ++++++++++ root/defaults/lighttpd.conf | 25 ++++++++++++ root/defaults/rsyncd.conf | 4 ++ root/defaults/stats | 34 ++++++++++++++++ .../s6-rc.d/init-lighttpd-config/run | 16 ++++++++ .../s6-rc.d/init-lighttpd-config/type | 1 + .../s6-rc.d/init-lighttpd-config/up | 1 + .../s6-overlay/s6-rc.d/init-rsync-config/run | 16 ++++++++ .../s6-overlay/s6-rc.d/init-rsync-config/type | 1 + .../s6-overlay/s6-rc.d/init-rsync-config/up | 1 + .../s6-overlay/s6-rc.d/init-vnstat-config/run | 12 ++++++ .../s6-rc.d/init-vnstat-config/trype | 1 + .../s6-overlay/s6-rc.d/init-vnstat-config/up | 1 + .../s6-overlay/s6-rc.d/svc-cron/dependencies | 3 ++ root/etc/s6-overlay/s6-rc.d/svc-cron/run | 3 ++ root/etc/s6-overlay/s6-rc.d/svc-cron/up | 1 + .../s6-rc.d/svc-lighttpd/dependencies | 1 + root/etc/s6-overlay/s6-rc.d/svc-lighttpd/run | 3 ++ root/etc/s6-overlay/s6-rc.d/svc-lighttpd/up | 1 + .../s6-rc.d/user/contents.d/svc-cron | 0 .../s6-rc.d/user/contents.d/svc-lighttpd | 0 24 files changed, 194 insertions(+), 61 deletions(-) create mode 100644 root/defaults/alpine-mirror create mode 100644 root/defaults/lighttpd.conf create mode 100644 root/defaults/rsyncd.conf create mode 100644 root/defaults/stats create mode 100644 root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/type create mode 100644 root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/up create mode 100644 root/etc/s6-overlay/s6-rc.d/init-rsync-config/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-rsync-config/type create mode 100644 root/etc/s6-overlay/s6-rc.d/init-rsync-config/up create mode 100644 root/etc/s6-overlay/s6-rc.d/init-vnstat-config/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-vnstat-config/trype create mode 100644 root/etc/s6-overlay/s6-rc.d/init-vnstat-config/up create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-cron/run create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-cron/up create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-lighttpd/dependencies create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-lighttpd/run create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-lighttpd/up create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-cron create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-lighttpd diff --git a/Dockerfile b/Dockerfile index 07bb5b9..547e824 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,22 @@ -# Example Dockerfile for amd64 -ARG BASE_IMAGE=alpine:latest +ARG BUILD_BASE_IMAGE +FROM ${BUILD_BASE_IMAGE} -FROM ${BASE_IMAGE} +ARG BUILD_DATE +ARG BUILD_APP_VERSION +ARG BUILD_MAINTAINER +ARG DESCRIPTION +ARG BUILD_APPS -ARG MAINTAINER -ARG TZ -ARG APP_NAME -ARG APP_USER +LABEL description=${DESCRIPTION} +LABEL build_version="${BUILD_MAINTAINER} version: ${BUILD_APP_VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="${BUILD_MAINTAINER}" -LABEL maintainer="${MAINTAINER}" -LABEL org.opencontainers.image.title="${APP_NAME}" +RUN apk add --no-cache ${BUILD_APPS} -ENV TZ=${TZ} -ENV USER=${APP_USER} +COPY root/ / -RUN apk add --no-cache tzdata ca-certificates +EXPOSE 80 -WORKDIR /app -COPY ./config /app/config -COPY ./data /app/data +VOLUME ["/config","/app/www"] -RUN adduser -D ${APP_USER} && chown -R ${APP_USER}:${APP_USER} /app - -USER ${APP_USER} - -CMD ["sh"] \ No newline at end of file +ENTRYPOINT ["/init"] \ No newline at end of file diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index f02657b..547e824 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,27 +1,22 @@ -# Example Dockerfile for arm64 -ARG BASE_IMAGE=alpine:latest +ARG BUILD_BASE_IMAGE +FROM ${BUILD_BASE_IMAGE} -FROM ${BASE_IMAGE} +ARG BUILD_DATE +ARG BUILD_APP_VERSION +ARG BUILD_MAINTAINER +ARG DESCRIPTION +ARG BUILD_APPS -ARG MAINTAINER -ARG TZ -ARG APP_NAME -ARG APP_USER +LABEL description=${DESCRIPTION} +LABEL build_version="${BUILD_MAINTAINER} version: ${BUILD_APP_VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="${BUILD_MAINTAINER}" -LABEL maintainer="${MAINTAINER}" -LABEL org.opencontainers.image.title="${APP_NAME}" +RUN apk add --no-cache ${BUILD_APPS} -ENV TZ=${TZ} -ENV USER=${APP_USER} +COPY root/ / -RUN apk add --no-cache tzdata ca-certificates +EXPOSE 80 -WORKDIR /app -COPY ./config /app/config -COPY ./data /app/data +VOLUME ["/config","/app/www"] -RUN adduser -D ${APP_USER} && chown -R ${APP_USER}:${APP_USER} /app - -USER ${APP_USER} - -CMD ["sh"] \ No newline at end of file +ENTRYPOINT ["/init"] \ No newline at end of file diff --git a/buildargs.env b/buildargs.env index dad5f2a..5eb343d 100644 --- a/buildargs.env +++ b/buildargs.env @@ -1,26 +1,23 @@ ## BUILD STAGE -BUILD_TAG=1.00 -BUILD_BASE_IMAGE=alpine:${BUILD_TAG} -## Examples for BUILD_BASE_IMAGE -# alpine:${BUILD_TAG} -# git.pi-farm.de/pi-farm/docker-baseimage-alpine:v${BUILD_TAG} -#BUILD_ALPINE_ARCH_AMD64=x86_64 -#BUILD_ALPINE_ARCH_AARCH64=aarch64 -#BUILD_S6_ARCH_amd64=x86_64 -#BUILD_S6_ARCH_aarch64=aarch64 -#BUILD_S6_OVERLAY_VERSION=3.2.0.2 -#BUILD_MAINTAINER=pi-farm -#BUILD_APP_VERSION=v${BUILD_TAG} -#BUILD_APP_NAME=basimage-alpine -#BUILD_APP_USER=pi -#BUILD_APP_GID=1000 +BUILD_TAG=3.23 +BUILD_BASE_IMAGE=git.pi-farm.de/pi-farm/docker-baseimage-alpine:3.23 +BUILD_MAINTAINER=pi-farm +BUILD_APP_VERSION=v${BUILD_TAG} +BUILD_APP_NAME=alpine-mirror +BUILD_APP_USER=pi +BUILD_APP_UID=1000 +BUILD_APP_GID=1000 +BUILD_APPS=lighttpd,\ +lighttpd-mod_auth,\ +rsync,\ +vnstat ## ENV STAGE ENV_TZ=Europe/Berlin ENV_PUID=1000 ENV_PGID=1000 -# VOL_CONFIG=./config:/config -# VOL_DATA=./data:/data -# PORT_WEB=8080:80 -#PUSH=gitea,dockerhub -DESCRIPTION="Example example example" - +VOL_CONFIG=./config:/config +VOL_DATA=./data:/app/www +PORT_WEB=8080:80 +PUSH=gitea +#,dockerhub +DESCRIPTION="Alpine Mirror with s6-overlay and lighttpd, rsync, vnstat, cron" diff --git a/root/defaults/alpine-mirror b/root/defaults/alpine-mirror new file mode 100644 index 0000000..e6ff686 --- /dev/null +++ b/root/defaults/alpine-mirror @@ -0,0 +1,21 @@ +#!/bin/sh +# make sure we never run 2 rsync at the same time +lockfile="/tmp/alpine-mirror.lock" +if [ -z "$flock" ] ; then + exec env flock=1 flock -n $lockfile "$0" "$@" +fi +src=rsync://rsync.alpinelinux.org/alpine/ +dest=/app/www/alpine/ + +exclude="--exclude v2.* --exclude v3.23 --exclude v3.1 --exclude v3.2 --exclude v3.3 --exclude v3.4 --exclude v3.5 --exclude v3.6 --exclude v3.7 --exclude v3.8 --exclude v3.9 --exclude v3.10 --exclude v3.11 --exclude v3.12 --exclude v3.13 --exclude v3.14 --exclude v3.15 --exclude> +mkdir -p "$dest" +/usr/bin/rsync \ + --archive \ + --update \ + --hard-links \ + --delete \ + --delete-after \ + --delay-updates \ + --timeout=600 \ + $exclude \ + "$src" "$dest" \ No newline at end of file diff --git a/root/defaults/lighttpd.conf b/root/defaults/lighttpd.conf new file mode 100644 index 0000000..e451553 --- /dev/null +++ b/root/defaults/lighttpd.conf @@ -0,0 +1,25 @@ +server.document-root = "/app/www/alpine" + +server.port = 80 + +server.username = "pi" +server.groupname = "users" + +mimetype.assign = ( + ".html" => "text/html", + ".txt" => "text/plain", + ".jpg" => "image/jpeg", + ".png" => "image/png", + ".css" => "text/css", + ".js" => "application/x-javascript", + ".svg" => "image/svg+xml" +) + +dir-listing.activate = "enable" + +server.modules += ( "mod_access", "mod_accesslog", "mod_setenv" ) +index-file.names = ( "index.html" ) +server.event-handler = "linux-sysepoll" +setenv.add-response-header += ( + "Cache-Control" => "must-revalidate" +) \ No newline at end of file diff --git a/root/defaults/rsyncd.conf b/root/defaults/rsyncd.conf new file mode 100644 index 0000000..da3d0aa --- /dev/null +++ b/root/defaults/rsyncd.conf @@ -0,0 +1,4 @@ +[alpine] + path = /app/www/alpine + comment = My Alpine Linux Mirror + RSYNC_OPTS="--bwlimit=500" \ No newline at end of file diff --git a/root/defaults/stats b/root/defaults/stats new file mode 100644 index 0000000..6ee28da --- /dev/null +++ b/root/defaults/stats @@ -0,0 +1,34 @@ +#!/bin/sh + +output="/app/www/.stats" +nic="eth0" + +generate_index() { + cat <<-EOF + + + + + + + Alpine Linux mirror statistics + + + + + + +
summaryhours
daystop10
months
+ + + EOF +} + +if [ ! -f "$output"/index.html ]; then + mkdir -p $output + generate_index > "$output"/index.html +fi + +for type in hours days months top10 summary hsummary vsummary; do + vnstati --${type} -i $nic -o $output/${type}.png +done \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/run b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/run new file mode 100644 index 0000000..792b89d --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/run @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bash + +echo "Start: init-lighttpd-config run script" + +mkdir -p /config /app/www + +if [ ! -f /config/lighttpd.conf ]; then + echo "Copy default-config..." + cp /defaults/lighttpd.conf /config/lighttpd.conf +fi + +echo "Set permissions to PUID: ${PUID:-911} and PGID: ${PGID:-1000}" +chown -R "${PUID:-911}:${PGID:-1000}" /config +chown -R "${PUID:-911}:${PGID:-1000}" /app/www + +echo "Finish: init-lighttpd-config" \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/type b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/up b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/up new file mode 100644 index 0000000..6422f3a --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-lighttpd-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-lighttpd-config/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-rsync-config/run b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/run new file mode 100644 index 0000000..e25b4dc --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/run @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bash + +echo "Start: init-rsync-config run script" + +mkdir -p /config /app/www + +if [ ! -f /config/rsyncd.conf ]; then + echo "Copy default-config..." + cp /defaults/rsyncd.conf /config/rsyncd.conf +fi + +echo "Set permissions to PUID: ${PUID:-911} and PGID: ${PGID:-1000}" +chown -R "${PUID:-911}:${PGID:-1000}" /config +chown -R "${PUID:-911}:${PGID:-1000}" /app/www + +echo "Finish: init-rsync-config" \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-rsync-config/type b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-rsync-config/up b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/up new file mode 100644 index 0000000..6567c7a --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-rsync-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-rsync-config/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/run b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/run new file mode 100644 index 0000000..b56d3d0 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/run @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bash + +echo "Start: init-vnstat-config run script" + +mkdir -p /config /app/www + +if [ ! -f /etc/periodic/15min/stats ]; then + echo "Copy default-config..." + cp /defaults/stats /etc/periodic/15min/stats +fi + +echo "Finish: init-vnstat-config" \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/trype b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/trype new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/trype @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/up b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/up new file mode 100644 index 0000000..191a869 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-vnstat-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-vnstat-config/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies b/root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies new file mode 100644 index 0000000..a7db5a8 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies @@ -0,0 +1,3 @@ +init-lighttpd-config +init-rsync-config +init-vnstat-config \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/run b/root/etc/s6-overlay/s6-rc.d/svc-cron/run new file mode 100644 index 0000000..3ce87e2 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-cron/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash + +exec crond -f \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/up b/root/etc/s6-overlay/s6-rc.d/svc-cron/up new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-cron/up @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/dependencies b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/dependencies new file mode 100644 index 0000000..ae5f393 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/dependencies @@ -0,0 +1 @@ +init-lighttpd-config \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/run b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/run new file mode 100644 index 0000000..ca24306 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash + +exec lighttpd -D -f /config/lighttpd.conf \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/up b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/up new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-lighttpd/up @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-cron b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-cron new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-lighttpd b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-lighttpd new file mode 100644 index 0000000..e69de29