Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to run in docker container for systems without php #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "$@"