From 40a6a738260bf4707b40e3edd26036ad24622e0e Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Fri, 3 Jun 2022 15:15:31 +0000 Subject: [PATCH] Initial commit --- Dockerfile | 21 +++++++++++++++++++++ run.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Dockerfile create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8a7dcc6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine:3.13 + +RUN apk update && \ + apk add bash gawk cyrus-sasl cyrus-sasl-login cyrus-sasl-crammd5 mailx \ + postfix postfix-pgsql && \ + rm -rf /var/cache/apk/* && \ + mkdir -p /var/log/supervisor/ /var/run/supervisor/ && \ + touch /etc/postfix/pgsql-relay-domains.cf && \ + touch /etc/postfix/pgsql-transport-maps.cf && \ + echo 'maillog_file = /dev/stdout' >> /etc/postfix/main.cf && \ + sed -i -e 's/inet_interfaces = localhost/inet_interfaces = all/g' /etc/postfix/main.cf + +RUN mkdir /config + +COPY run.sh / +RUN chmod +x /run.sh +RUN newaliases + +EXPOSE 25 +#ENTRYPOINT ["/run.sh"] +CMD ["/run.sh"] \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..5ab4655 --- /dev/null +++ b/run.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +[ "${DEBUG}" == "yes" ] && set -x + +function add_config_value() { + local key=${1} + local value=${2} + # local config_file=${3:-/etc/postfix/main.cf} + [ "${key}" == "" ] && echo "ERROR: No key set !!" && exit 1 + [ "${value}" == "" ] && echo "ERROR: No value set !!" && exit 1 + + echo "Setting configuration option ${key} with value: ${value}" + postconf -e "${key} = ${value}" +} + +#Copy files into config dir + +#Move missing files from Postfix to /config +mv -n /etc/postfix/main.cf /config/main.cf +mv -n /etc/postfix/master.cf /config/master.cf +mv -n /etc/postfix/pgsql-relay-domains.cf /config/pgsql-relay-domains.cf +mv -n /etc/postfix/pgsql-transport-maps.cf /config/pgsql-transport-maps.cf + +#Delete files from Postfix +rm /etc/postfix/main.cf +rm /etc/postfix/master.cf +rm /etc/postfix/pgsql-relay-domains.cf +rm /etc/postfix/pgsql-transport-maps.cf + +#Link files into Postfix +ln -s /config/main.cf /etc/postfix/main.cf +ln -s /config/pgsql-relay-domains.cf /etc/postfix/pgsql-relay-domains.cf +ln -s /config/pgsql-transport-maps.cf /etc/postfix/pgsql-transport-maps.cf +ln -s /config/master.cf /etc/postfix/master.cf + +#Start services + +# If host mounting /var/spool/postfix, we need to delete old pid file before +# starting services +rm -f /var/spool/postfix/pid/master.pid + +exec /usr/sbin/postfix -c /etc/postfix start-fg \ No newline at end of file