Skip to content

Commit

Permalink
Merge pull request #5 from olzhasar-reef/olzhasar-fix-certs-renewal
Browse files Browse the repository at this point in the history
Fix certificates renewal cron
  • Loading branch information
mjurbanski-reef authored Apr 25, 2024
2 parents 328a206 + a2d7fe4 commit 93a801a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN set -ex \
exit 1; \
fi

COPY ./ /modules/
COPY modules /modules/

RUN set -ex \
&& apk update \
Expand Down Expand Up @@ -75,7 +75,15 @@ RUN set -ex \
&& rm -rf /tmp/packages

COPY entrypoint/*.sh /docker-entrypoint.d/

COPY etc/nginx/* /etc/nginx/

ARG certbot_cron_period="daily"

COPY scripts /scripts/
RUN chmod +x /scripts/run_certbot

RUN mkdir -p /etc/periodic/${certbot_cron_period}
RUN ln -s /scripts/run_certbot /etc/periodic/${certbot_cron_period}/run_certbot


EXPOSE 80 443
16 changes: 2 additions & 14 deletions entrypoint/50-letsencrypt-renew.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/sh
set -eu

echo "Running certbot renew on startup..."
certbot --nginx renew

cron_dir=""

[ -d "/etc/periodic/daily/" ] && cron_dir="/etc/periodic/daily";
[ -d "/etc/cron.daily" ] && cron_dir="/etc/cron.daily";
[ ! "$cron_dir" = "" ] || exit 1;

certbot_file="${cron_dir}/certbot"
echo "Installing Let's Encrypt crontab script into $certbot_file"
echo "#!/bin/sh" > "$certbot_file"
echo "certbot -q --nginx renew" >> "$certbot_file"
chmod +x "$certbot_file"
# Run certbot renew in the background on startup
./scripts/run_certbot &
5 changes: 5 additions & 0 deletions entrypoint/99-crond.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -eu

# Start the cron daemon
crond
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/run_certbot
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# The script for renewing the SSL certificates

exec certbot --nginx renew > /proc/1/fd/1 2>/proc/1/fd/2

0 comments on commit 93a801a

Please sign in to comment.