dovecot: Consolidate container build instructions

This improves cacheability of layers by consolidating instructions
across different container builds. Future work will involve installing
from an external binary repository.
This commit is contained in:
Alex Palaistras 2024-01-02 15:31:49 +00:00
parent a43f5a0c1f
commit 524384051d
2 changed files with 16 additions and 12 deletions

View File

@ -1,17 +1,20 @@
FROM docker.io/debian:bookworm-slim@sha256:f80c45482c8d147da87613cb6878a7238b8642bcc24fc11bad78c7bec726f340 FROM docker.io/debian:bookworm-slim@sha256:f80c45482c8d147da87613cb6878a7238b8642bcc24fc11bad78c7bec726f340
ARG VERSION=2.3.19 # renovate: datasource=repology depName=debian_12/dovecot versioning=loose RUN apt-get update -y && apt-get upgrade -y && \
apt-get install -y --no-install-recommends ca-certificates gettext gosu
RUN apt-get update -y && apt-get install -y --no-install-recommends \ RUN apt-get update -y && apt-get install -y --no-install-recommends \
dovecot-imapd=1:${VERSION}* dovecot-lmtpd=1:${VERSION}* dovecot-mysql=1:${VERSION}* \ curl netcat-traditional
dovecot-sieve=1:${VERSION}* dovecot-managesieved=1:${VERSION}* dovecot-fts-xapian \
gettext ca-certificates curl netcat-traditional ARG VERSION=2.3.19 # renovate: datasource=repology depName=debian_12/dovecot versioning=loose
RUN apt-get update -y && apt-get install -y --no-install-recommends \
dovecot-imapd=1:${VERSION}* dovecot-lmtpd=1:${VERSION}* dovecot-mysql=1:${VERSION}* \
dovecot-sieve=1:${VERSION}* dovecot-managesieved=1:${VERSION}* dovecot-fts-xapian && \
rm -Rf /etc/dovecot
RUN adduser --system --group --uid 10000 --home /var/mail/virtual virtual
RUN rm -Rf /etc/dovecot
COPY container/config /etc/dovecot COPY container/config /etc/dovecot
COPY container/run-dovecot /run-dovecot COPY container/run-dovecot /run-dovecot
RUN addgroup --system --gid 5000 virtual
RUN adduser --system --uid 5000 --ingroup virtual --home /var/mail/virtual virtual
EXPOSE 24 143 993 3659 4190 EXPOSE 24 143 993 3659 4190
ENTRYPOINT ["/run-dovecot"] ENTRYPOINT ["/run-dovecot"]

View File

@ -1,9 +1,10 @@
#!/bin/sh #!/bin/sh
set -eu
# Prepare configuration files for environment variable substitution. # Prepare configuration files for environment variable substitution.
ENV_NAMES="$(env | awk -F= '{printf "$%s ", $1}')" ENV_NAMES="$(env | awk -F '=' '{printf "$%s ", $1}')"
for file in /etc/dovecot/*.template; do for file in /etc/dovecot/*.template; do
envsubst "$ENV_NAMES" < "$file" > "$(echo "$file" | awk -F '.template$' '{print $1}')" envsubst "$ENV_NAMES" < "$file" > "${file%.template}"
done done
# Compile Sieve scripts and ensure correct permissions. # Compile Sieve scripts and ensure correct permissions.
@ -11,7 +12,7 @@ find /etc/dovecot -name '*.sieve' -execdir sievec {} \;
find /etc/dovecot -name '*.script' -execdir chmod 0755 {} \; find /etc/dovecot -name '*.script' -execdir chmod 0755 {} \;
# Set up environment variables for Rspamd integration. # Set up environment variables for Rspamd integration.
env | awk -F_ '$1 == "RSPAMD" {print $0}' > /etc/dovecot/rspamd.env env | awk -F '_' '$1 == "RSPAMD" {print $0}' > /etc/dovecot/rspamd.env
# Run Dovecot daemon. # Run Dovecot daemon.
/usr/sbin/dovecot -F exec /usr/sbin/dovecot -F