Ditch `cron` for `bash`
This commit is contained in:
parent
844d521c95
commit
b8b50ae5da
|
@ -8,7 +8,7 @@ EXPOSE 443
|
||||||
# Do this apt/pip stuff all in one RUN command to avoid creating large
|
# Do this apt/pip stuff all in one RUN command to avoid creating large
|
||||||
# intermediate layers on non-squashable docker installs
|
# intermediate layers on non-squashable docker installs
|
||||||
RUN apt update && \
|
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 && \
|
curl -L 'https://bootstrap.pypa.io/get-pip.py' | python && \
|
||||||
pip install -U cffi certbot && \
|
pip install -U cffi certbot && \
|
||||||
apt remove --purge -y python-dev build-essential libffi-dev libssl-dev curl && \
|
apt remove --purge -y python-dev build-essential libffi-dev libssl-dev curl && \
|
||||||
|
@ -16,8 +16,7 @@ RUN apt update && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy in cron job and scripts for certbot
|
# Copy in scripts for certbot
|
||||||
COPY ./crontab /etc/cron.d/certbot
|
|
||||||
COPY ./scripts/ /scripts
|
COPY ./scripts/ /scripts
|
||||||
RUN chmod +x /scripts/*.sh
|
RUN chmod +x /scripts/*.sh
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ This repository was originally forked from `@henridwyer`, many thanks to him for
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
### 0.8
|
||||||
|
- Ditch cron, it never liked me anway. Just use `sleep` and a `while` loop instead.
|
||||||
|
|
||||||
### 0.7
|
### 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.
|
- 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.
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,15 @@ for f in /scripts/startup/*.sh; do
|
||||||
done
|
done
|
||||||
echo "Done with startup"
|
echo "Done with startup"
|
||||||
|
|
||||||
# Run `cron -f &` so that it's a background job owned by bash and then `wait`.
|
# Instead of trying to run `cron` or something like that, just leep and run `certbot`.
|
||||||
# This allows SIGINT (e.g. CTRL-C) to kill cron gracefully, due to our `trap`.
|
while [ true ]; do
|
||||||
cron -f &
|
# Sleep for 1 week
|
||||||
wait "$NGINX_PID"
|
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
|
||||||
|
|
Loading…
Reference in New Issue