Skip to content

Commit 6e82240

Browse files
committed
docker: Restore ability to generate SSL certs with LetsEncrypt.
Zulip Server 4.9+ regressed Docker setups by always creating a /etc/letsencrypt directory in the top layer of the Docker container, meaning it couldn't be symlinked over from the volume mount. Since that volume mount has useful properties (providing and/or overriding LetsEncrypt setting), restore it and copy the in-image configs into the volume as defaults if and only if those files don't already exist in the volume. Fixes #381.
1 parent d9bc5bb commit 6e82240

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Dockerfile

+11-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,17 @@ RUN \
7373
rm -f /etc/zulip/zulip-secrets.conf /etc/zulip/settings.py && \
7474
apt-get -qq autoremove --purge -y && \
7575
apt-get -qq clean && \
76-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
76+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
77+
mv /etc/letsencrypt /etc/letsencrypt.zulip
78+
# ^ Zulip Server installs LetsEncrypt with some default settings. We want to
79+
# allow /etc/letsencrypt to be volume mountable from the host while retaining
80+
# these settings unless overridden, so let's unclobber this path so that
81+
# entrypoint.sh can symlink from the volume mount and repopulate any missing
82+
# default files.
83+
#
84+
# This incantation must be part of the same layer that creates
85+
# /etc/letsencrypt/renewal-hooks to avoid Directory Not Empty / Invalid
86+
# Argument errors attempting to rename or unlink it.
7787

7888
COPY entrypoint.sh /sbin/entrypoint.sh
7989
COPY certbot-deploy-hook /sbin/certbot-deploy-hook

entrypoint.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ SETTINGS_PY="/etc/zulip/settings.py"
5151
# === initialConfiguration ===
5252
prepareDirectories() {
5353
mkdir -p "$DATA_DIR" "$DATA_DIR/backups" "$DATA_DIR/certs" "$DATA_DIR/letsencrypt" "$DATA_DIR/uploads"
54-
[ -e /etc/letsencrypt ] || ln -ns "$DATA_DIR/letsencrypt" /etc/letsencrypt
54+
55+
# See commentary in the Dockerfile about this process.
56+
if [ -e /etc/letsencrypt ]; then
57+
echo "Found unexpected /etc/letsencrypt in the Docker image, are you using the latest build?" >&2
58+
exit 1
59+
fi
60+
ln -s "${DATA_DIR}/letsencrypt" /etc/letsencrypt
61+
cp -an /etc/letsencrypt.zulip/* /etc/letsencrypt/
62+
5563
echo "Preparing and linking the uploads folder ..."
5664
rm -rf /home/zulip/uploads
5765
ln -sfT "$DATA_DIR/uploads" /home/zulip/uploads

0 commit comments

Comments
 (0)