diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b514e2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM php:8.2-cli-alpine +COPY . / +WORKDIR / + +ENV SCHEDULE="*/5 * * * *" \ + CRON_CMD="php /update.php" + +ENTRYPOINT ["/entrypoint.sh"] + +CMD ["/usr/sbin/crond", "-f"] + +SHELL ["/bin/ash"] diff --git a/README.md b/README.md index 6c3ee6e..405378e 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ Configuration is very simple: You should probably run this script every few minutes, so that your IP is updated as quickly as possible. Add it to your cronjobs and run it regularly, for example every five minutes. +### How to use - alternative with Docker +`docker compose up` + +The docker container includes the cronjob and runs by default every 5 minutes. + ### CLI options Just add these Options after the command like `./update.php --quiet` diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..1f1b181 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3' + +services: + netcup-dyndns: + restart: unless-stopped + network_mode: host + environment: + - SCHEDULE="*/5 * * * *" + build: + context: . + dockerfile: Dockerfile diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..bd1863c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/ash -e + +echo "startup $0" + +if [ ! -z "${SCHEDULE}" ] && [ ! -z "${CRON_CMD}" ]; then + echo "configure cron: ${SCHEDULE} ${CRON_CMD}" + echo "@reboot ${CRON_CMD}" > /etc/crontabs/root + echo "${SCHEDULE} ${CRON_CMD}" >> /etc/crontabs/root +fi + +echo "run: $@" +exec "$@" +