diff --git a/Dockerfile b/Dockerfile index 78b00b4..a8b431f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ EXPOSE 443 # Do this apt/pip stuff all in one RUN command to avoid creating large # intermediate layers on non-squashable docker installs RUN apt update && \ - apt install -y cron python python-dev libffi6 libffi-dev libssl-dev curl build-essential && \ + apt install -y python python-dev libffi6 libffi-dev libssl-dev curl build-essential && \ curl -L 'https://bootstrap.pypa.io/get-pip.py' | python && \ pip install -U cffi certbot && \ apt remove --purge -y python-dev build-essential libffi-dev libssl-dev curl && \ @@ -16,8 +16,7 @@ RUN apt update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Copy in cron job and scripts for certbot -COPY ./crontab /etc/cron.d/certbot +# Copy in scripts for certbot COPY ./scripts/ /scripts RUN chmod +x /scripts/*.sh diff --git a/README.md b/README.md index 7f769bb..da42a0f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ This repository was originally forked from `@henridwyer`, many thanks to him for # Changelog +### 0.8 +- Ditch cron, it never liked me anway. Just use `sleep` and a `while` loop instead. + ### 0.7 - Complete rewrite, build this image on top of the `nginx` image, and run `cron`/`certbot` alongside `nginx` so that we can have nginx configs dynamically enabled as we get SSL certificates. diff --git a/crontab b/crontab deleted file mode 100644 index d0d1317..0000000 --- a/crontab +++ /dev/null @@ -1 +0,0 @@ -0 */12 * * * root sh /scripts/run_certbot.sh diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index aff690a..b6445bf 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -26,7 +26,15 @@ for f in /scripts/startup/*.sh; do done echo "Done with startup" -# Run `cron -f &` so that it's a background job owned by bash and then `wait`. -# This allows SIGINT (e.g. CTRL-C) to kill cron gracefully, due to our `trap`. -cron -f & -wait "$NGINX_PID" +# Instead of trying to run `cron` or something like that, just leep and run `certbot`. +while [ true ]; do + # Sleep for 1 week + sleep 604800 & + SLEEP_PID=$! + + # re-run certbot + /scripts/run_certbot.sh + + # Wait on sleep so that when we get ctrl-c'ed it kills everything due to our trap + wait "$SLEEP_PID" +done