Skip to content

Commit

Permalink
Add support to run in docker container for systems without php
Browse files Browse the repository at this point in the history
  • Loading branch information
linkeal committed Jan 7, 2025
1 parent a8a6327 commit 1dd68da
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
netcup-dyndns:
restart: unless-stopped
network_mode: host
environment:
- SCHEDULE="*/5 * * * *"
build:
context: .
dockerfile: Dockerfile
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 1dd68da

Please sign in to comment.