hetzner-api-dyndns icon indicating copy to clipboard operation
hetzner-api-dyndns copied to clipboard

Dockerfile example alpine with cron enabled

Open FloCola opened this issue 3 years ago • 2 comments

quite handy, have it running on a Synology NAS. Should be running almost anywhere.

Preconfig:

  • Download script, save it accessible for the container.
  • Script: Change first line to '#!/bin/ash'
  • Script: Preconfigure Script-Parameters, or add script parameters to cronjob.
  • Dockerfile: Change echo for cronjobs to your needs. See example.
  • Mount Container Folder with scripts to '/srv'
# Dockerfile to create image with cron services
FROM alpine:latest

#Configure
RUN apk add --no-cache curl
RUN apk add --no-cache bind-tools
RUN apk add --no-cache jq

#Cronjobs
RUN echo '*/5     *       *       *       *       /bin/ash /srv/hetzner-dyndns_alpine.sh >> /srv/hetzner-dyndns.log' >> /root/crontab.conf


# Add the cron job
RUN crontab /root/crontab.conf

# Run the command on container startup
CMD [ "/usr/sbin/crond", "-f", "-d8" ]

FloCola avatar Aug 07 '22 13:08 FloCola

Awesome @FloCola! That helped me a lot :-)

kladderadeng avatar Mar 31 '23 13:03 kladderadeng

It's worth noting that installing bind-tools should no longer be necessary, as #35 uses an HTTP API to get the host's IP instead of using dig or nslookup.

It could be a good idea to automate Docker builds to GHCR.

thcrt avatar Dec 16 '23 15:12 thcrt