Docker: Support for setting cron schedule, PUID, GUID and time zone via env vars.
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 33s

This commit is contained in:
2026-04-26 22:43:51 +02:00
parent c70334e65e
commit ad365339b0
4 changed files with 77 additions and 24 deletions

View File

@@ -2,30 +2,27 @@ FROM alpine:latest
ENV TZ="UTC"
ENV SCHEDULE="* * * * *"
ENV PUID=1000
ENV PGID=1000
## Configure runtime variables for nsupdate
ENV NSUPDATE_CONFD_DIR="/config"
ENV NSUPDATE_LOG_DIR="/log"
## Install requirements
RUN apk update
RUN apk add --no-cache git curl libxml2-utils tzdata jq
# Read timezone from server, so in docker-compose you can change TZ
RUN ln -sf "/usr/share/zoneinfo/${TZ}" /etc/localtime && \
echo "${TZ}" > /etc/timezone && date
# Cache Bust upon new commits
ADD https://api.github.com/repos/chrisb86/nsupdate/git/refs/heads/main /.git-hashref
COPY nsupdate.sh /usr/local/bin/nsupdate.sh
RUN chmod +x /usr/local/bin/nsupdate.sh
COPY --chmod=755 nsupdate.sh /usr/local/bin/nsupdate.sh
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/entrypoint.sh
## Setup cron job
RUN echo "${SCHEDULE} sh /usr/local/bin/nsupdate.sh" >> /etc/crontabs/root
# Create volume directories (ownership will be set at runtime)
RUN mkdir -p /config /log
## Start crond
CMD [ "crond", "-l", "2", "-f" ]
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
VOLUME /config
VOLUME /log
VOLUME /log