Skip to content

Commit

Permalink
Align letsencrypt docker container to geonode-project (#9717) (#9769)
Browse files Browse the repository at this point in the history
Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
github-actions[bot] and afabiani authored Jul 27, 2022
1 parent 3a69026 commit 4ccfb47
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions scripts/docker/letsencrypt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM certbot/certbot:v1.21.0
FROM alpine:3.14

RUN apk add --no-cache certbot

# Installing scripts
ADD docker-entrypoint.sh /docker-entrypoint.sh
Expand All @@ -10,7 +12,6 @@ RUN /usr/bin/crontab /crontab && \
rm /crontab

# Setup the entrypoint
WORKDIR /
ENTRYPOINT ["./docker-entrypoint.sh"]

# We run cron in foreground to update the certificates
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/letsencrypt/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Letsencrypt service for SPCGeonode
# Letsencrypt service for Geonode

This service generates SSL certificates to be used by Nginx.

Expand Down
12 changes: 6 additions & 6 deletions scripts/docker/letsencrypt/crontab
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ┌───────────── minute (0 - 59)
# ┌───────────── hour (0 - 23)
# ┌───────────── day of month (1 - 31)
# ┌───────────── month (1 - 12)
# ┌───────────── day of week (0 - 6) (Sunday to Saturday; 7 is also Sunday on some systems)
#
# +------------- minute (0 - 59)
# ¦ +------------- hour (0 - 23)
# ¦ ¦ +------------- day of month (1 - 31)
# ¦ ¦ ¦ +------------- month (1 - 12)
# ¦ ¦ ¦ ¦ +------------- day of week (0 - 6) (Sunday to Saturday; 7 is also Sunday on some systems)
# ¦ ¦ ¦ ¦ ¦

0 0,12 * * * date && echo "daily " && /docker-entrypoint.sh
5 changes: 4 additions & 1 deletion scripts/docker/letsencrypt/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ set +e
# We run the command
if [ "$LETSENCRYPT_MODE" == "staging" ]; then
printf "\nTrying to get STAGING certificate\n"
certbot --config-dir "/geonode-certificates/$LETSENCRYPT_MODE" certonly --webroot -w "/geonode-certificates" -d "$HTTPS_HOST" -m "$ADMIN_EMAIL" --agree-tos --non-interactive --staging
certbot --config-dir "/geonode-certificates/$LETSENCRYPT_MODE" certonly --webroot -w "/geonode-certificates" -d "$HTTPS_HOST" -m "$ADMIN_EMAIL" --agree-tos --non-interactive --test-cert
elif [ "$LETSENCRYPT_MODE" == "production" ]; then
printf "\nTrying to get PRODUCTION certificate\n"
certbot --config-dir "/geonode-certificates/$LETSENCRYPT_MODE" certonly --webroot -w "/geonode-certificates" -d "$HTTPS_HOST" -m "$ADMIN_EMAIL" --agree-tos --non-interactive --server https://acme-v02.api.letsencrypt.org/directory
elif [ "$LETSENCRYPT_MODE" == "disabled" ]; then
printf "\nNot trying to get certificate (because LETSENCRYPT_MODE variable is set to disabled) - and stop container\n"
exit 0
else
printf "\nNot trying to get certificate (simulating failure, because LETSENCRYPT_MODE variable was neither staging nor production\n"
/bin/false
Expand Down

0 comments on commit 4ccfb47

Please sign in to comment.