Compare commits

..

No commits in common. "e7923cf4cb56ac698da44fb9afab8f08bd21e47c" and "702d3529888fdf3b5c6cf49445036dfdc15362e1" have entirely different histories.

3 changed files with 72 additions and 91 deletions

View File

@ -1,5 +1,5 @@
# #
# simple postfix smtp relay # simple postfix smarthost smtp relay
# #
FROM alpine:3.13 FROM alpine:3.13
@ -9,13 +9,13 @@ LABEL author="Asif Bacchus <asif@bacchus.cloud>"
LABEL maintainer="Asif Bacchus <asif@bacchus.cloud>" LABEL maintainer="Asif Bacchus <asif@bacchus.cloud>"
LABEL org.label-schema.schema-version="1.0" LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.docker.cmd="" LABEL org.label-schema.docker.cmd=""
LABEL org.label-schema.description="Simple postfix smtp mail relay on Alpine." LABEL org.label-schema.description="Simple postfix smarthost smtp mail relay on Alpine Linux."
LABEL org.label-schema.url="https://git.asifbacchus.app/ab-docker/postfix-smtp-relay" LABEL org.label-schema.url=""
LABEL org.label-schema.usage="https://git.asifbacchus.app/ab-docker/postfix-smtp-relay" LABEL org.label-schema.usage=""
LABEL org.label-schema.vcs-url="https://git.asifbacchus.app/ab-docker/postfix-smtp-relay.git" LABEL org.label-schema.vcs-url=""
# install packages and clean-up # install mSMTP
RUN apk --no-cache add \ RUN apk --no-cache \
ca-certificates \ ca-certificates \
postfix \ postfix \
bind-tools \ bind-tools \
@ -23,8 +23,8 @@ RUN apk --no-cache add \
# set environment variables # set environment variables
ENV TZ=Etc/UTC ENV TZ=Etc/UTC
ENV LOCAL_HOSTNAME="" ENV LOCAL_HOSTNAME=${HOSTNAME}
ENV LOCAL_DOMAINNAME="" ENV LOCAL_DOMAINNAME=${HOSTNAME#*.}
ENV LOCAL_ENCRYPTION=false ENV LOCAL_ENCRYPTION=false
ENV SMARTHOST="" ENV SMARTHOST=""
ENV SMARTHOST_PORT=587 ENV SMARTHOST_PORT=587
@ -41,8 +41,8 @@ ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
CMD [ "/usr/local/sbin/postfix", "start-fg" ] CMD [ "/usr/local/sbin/postfix", "start-fg" ]
# set parameters, vendor, version and build-date labels # set parameters, vendor, version and build-date labels
LABEL org.label-schema.docker.params="TZ=Etc/UTC, HOSTNAME=(container hostname), DOMAINNAME=(derived from hostname), LOCAL_ENCRYPTION=false|optional|true, SMARTHOST=..., SMARTHOST_PORT=587, SMARTHOST_USERNAME=..., SMARTHOST_PASSWORD=..., SMARTHOST_ENCRYPTION=optional|false|true" LABEL org.label-schema.docker.params="TZ=Etc/UTC, HOSTNAME=HOSTNAME, DOMAINNAME=(derived from hostname), LOCAL_ENCRYPTION=false, SMARTHOST, SMARTHOST_PORT=587, SMARTHOST_USERNAME, SMARTHOST_PASSWORD, SMARTHOST_ENCRYPTION='OPTIONAL'"
LABEL org.label-schema.vendor="Alpine 3.13, Postfix 3.5.10-r0" LABEL org.label-schema.vendor="Alpine 3.13, Postfix 3.5.10-r0"
LABEL org.label-schema.version="0.5" LABEL org.label-schema.version="0.1"
ARG BUILD_DATE ARG BUILD_DATE
LABEL org.label-schema.build-date=${BUILD_DATE} LABEL org.label-schema.build-date=${BUILD_DATE}

View File

@ -8,33 +8,23 @@ convertCase () {
printf "%s" "$1" | tr "[:lower:]" "[:upper:]" printf "%s" "$1" | tr "[:lower:]" "[:upper:]"
} }
if [ -f "/etc/postfix/main.cf.override" ]; then
# use provided configuration file
printf "\nAppending provided MAIN configuration... "
cat /etc/postfix/main.cf.override >> /etc/postfix/main.cf
\rm -f /tmp/main.cf.insert
else
# process auto-setup
printf "\nVerifying environment variables... " printf "\nVerifying environment variables... "
# check for missing environment variable values # check for missing environment variable values
if [ -z "$SMARTHOST" ]; then if [ -z "$SMARTHOST" ]; then
printf "\nYou must specify the hostname or IP address of a smarthost where mail should be relayed.\n\n" printf "\nYou must specify the hostname or IP address of a smarthost where mail should be relayed.\n\n"
exit 1
fi fi
if [ -z "$SMARTHOST_USERNAME" ]; then if [ -z "$SMARTHOST_USERNAME" ]; then
printf "\nYou must provide a username for smarthost authentication.\n\n" printf "\nYou must provide a username for smarthost authentication.\n\n"
exit 1
fi fi
if [ -z "$SMARTHOST_PASSWORD" ]; then if [ -z "$SMARTHOST_PASSWORD" ]; then
printf "\nYou must provide a password for smarthost authentication.\n\n" printf "\nYou must provide a password for smarthost authentication.\n\n"
exit 1
fi fi
# set failsafes # set failsafes
[ -z "$SMARTHOST_PORT" ] && SMARTHOST_PORT=587 [ -z "$SMARTHOST_PORT" ] && SMARTHOST_PORT=587
[ -z "$LOCAL_HOSTNAME" ] && LOCAL_HOSTNAME="$(uname -n)" [ -z "$LOCAL_HOSTNAME" ] && LOCAL_HOSTNAME="smarthost"
[ -z "$LOCAL_DOMAINNAME" ] && LOCAL_DOMAINNAME="${LOCAL_HOSTNAME#*.}" [ -z "$LOCAL_DOMAINNAME" ] && LOCAL_DOMAINNAME="smarthost"
printf "done\n" printf "done\n"
printf "updating configuration files... " printf "updating configuration files... "
@ -75,22 +65,13 @@ else
;; ;;
esac esac
# append configuration and remove temp file
cat /tmp/main.cf.insert >> /etc/postfix/main.cf cat /tmp/main.cf.insert >> /etc/postfix/main.cf
\rm -f /tmp/main.cf.insert rm -f /tmp/main.cf.insert
fi
printf "done\n"
if [ -f "/etc/postfix/master.cf.override" ]; then
# use provided configuration file
printf "\nUsing provided MASTER configuration... "
\cp --force /etc/postfix/master.cf.override /etc/postfix/master.cf
else
# update master.cf # update master.cf
sed -i 's/#tlsproxy/tlsproxy/' /etc/postfix/master.cf sed -i 's/#tlsproxy/tlsproxy/' /etc/postfix/master.cf
fi
printf "done\n"
printf "done\n"
printf "container setup complete!\n" printf "container setup complete!\n"
# run CMD passed to this container # run CMD passed to this container

View File

@ -13,7 +13,7 @@ relayhost = [{SMARTHOST}]:{SMARTHOST_PORT}
#smtpd_tls_chain_files = /certs/privkey.pem, /certs/fullchain.pem #smtpd_tls_chain_files = /certs/privkey.pem, /certs/fullchain.pem
#smtpd_tls_mandatory_ciphers = high #smtpd_tls_mandatory_ciphers = high
#smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5 #smptd_tls_mandatory_exclude_ciphers = aNULL, MD5
#smtpd_tls_mandatory_protocols = >=TLSv1.2 #smtpd_tls_mandatory_protocols = >=TLSv1.2
#smtpd_tls_security_level = {LOCAL_ENCRYPTION} #smtpd_tls_security_level = {LOCAL_ENCRYPTION}