From 524384051df3935650e6ea1975dc3b3089beae04 Mon Sep 17 00:00:00 2001 From: Alex Palaistras Date: Tue, 2 Jan 2024 15:31:49 +0000 Subject: [PATCH] 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. --- service/dovecot/Containerfile | 19 +++++++++++-------- service/dovecot/container/run-dovecot | 9 +++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/service/dovecot/Containerfile b/service/dovecot/Containerfile index 67a255b..048ff27 100644 --- a/service/dovecot/Containerfile +++ b/service/dovecot/Containerfile @@ -1,17 +1,20 @@ 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 \ - dovecot-imapd=1:${VERSION}* dovecot-lmtpd=1:${VERSION}* dovecot-mysql=1:${VERSION}* \ - dovecot-sieve=1:${VERSION}* dovecot-managesieved=1:${VERSION}* dovecot-fts-xapian \ - gettext ca-certificates curl netcat-traditional + 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/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 ENTRYPOINT ["/run-dovecot"] diff --git a/service/dovecot/container/run-dovecot b/service/dovecot/container/run-dovecot index cccdb97..ee53d48 100755 --- a/service/dovecot/container/run-dovecot +++ b/service/dovecot/container/run-dovecot @@ -1,9 +1,10 @@ #!/bin/sh +set -eu # 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 - envsubst "$ENV_NAMES" < "$file" > "$(echo "$file" | awk -F '.template$' '{print $1}')" + envsubst "$ENV_NAMES" < "$file" > "${file%.template}" done # 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 {} \; # 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. -/usr/sbin/dovecot -F +exec /usr/sbin/dovecot -F