From dfcae50ad964fc0df388d69815d713ec69e3e5ab Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Mon, 1 Jul 2024 14:58:24 -0400 Subject: [PATCH] Add postfix --- postfix/Dockerfile | 25 +++++++++++++++++++++++++ postfix/README.md | 7 +++++++ postfix/docker-entrypoint.sh | 6 ++++++ postfix/main.cf.tmpl | 26 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 postfix/Dockerfile create mode 100644 postfix/README.md create mode 100755 postfix/docker-entrypoint.sh create mode 100644 postfix/main.cf.tmpl diff --git a/postfix/Dockerfile b/postfix/Dockerfile new file mode 100644 index 0000000..91e1290 --- /dev/null +++ b/postfix/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:3.20 +ENV DOCKERIZE_VERSION v0.7.0 + +# install packages +RUN apk add --no-cache --update postfix bash && \ + apk add --no-cache --upgrade musl musl-utils && \ + (rm "/tmp/"* 2>/dev/null || true) && (rm -rf /var/cache/apk/* 2>/dev/null || true) + +# install dockerize +RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz + +# copy postfix config file template into image +COPY main.cf.tmpl /etc/postfix/main.cf.tmpl + +# copy entrypoint script into an image +COPY docker-entrypoint.sh / + +# postfix is listening on port 25 +EXPOSE 25 +STOPSIGNAL SIGKILL + +CMD /docker-entrypoint.sh + diff --git a/postfix/README.md b/postfix/README.md new file mode 100644 index 0000000..3a31cc4 --- /dev/null +++ b/postfix/README.md @@ -0,0 +1,7 @@ +# postfix + +Started with guide at https://www.iops.tech/blog/postfix-in-alpine-docker-container/ + +``` +Rebuild count: 0 +``` diff --git a/postfix/docker-entrypoint.sh b/postfix/docker-entrypoint.sh new file mode 100755 index 0000000..33a14d3 --- /dev/null +++ b/postfix/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#/usr/bin/env bash + +set -eou pipefail + +dockerize -template /etc/postfix/main.cf.tmpl:/etc/postfix/main.cf postfix start-fg + diff --git a/postfix/main.cf.tmpl b/postfix/main.cf.tmpl new file mode 100644 index 0000000..02055e9 --- /dev/null +++ b/postfix/main.cf.tmpl @@ -0,0 +1,26 @@ +maillog_file = /dev/stdout +smtp_helo_name = {{ .Env.POSTFIX_SMTP_HELO_NAME }} +myorigin = {{ .Env.POSTFIX_MYORIGIN }} + +smtpd_banner = $myhostname ESMTP +biff = no +append_dot_mydomain = no +readme_directory = no + +compatibility_level = 2 + +smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache +smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache + +smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination +myhostname = {{ .Env.POSTFIX_MYHOSTNAME }} +alias_maps = hash:/etc/aliases +alias_database = hash:/etc/aliases +mydestination = localhost.localdomain, localhost +relayhost = +mynetworks = 127.0.0.0/8 192.168.0.0/16 172.16.0.0/12 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all +inet_protocols = ipv4 +