Skip to content

Instantly share code, notes, and snippets.

@codebje
Created November 8, 2016 00:32
Show Gist options
  • Save codebje/3652d6c2118ba7b0f38a39e1ac39a56d to your computer and use it in GitHub Desktop.
Save codebje/3652d6c2118ba7b0f38a39e1ac39a56d to your computer and use it in GitHub Desktop.
FROM ubuntu:xenial
ENV DEBIAN_FRONTEND noninteractive
RUN rm -rf /var/lib/apt/lists/* && \
apt-get update -q -q && \
echo 'UTC' > /etc/timezone && \
dpkg-reconfigure tzdata
COPY postfix_3.0.4-5ubuntu1_amd64.deb /root/
RUN apt-get -y install libicu55 libsasl2-2 libsqlite3-0 libssl1.0.0 \
netbase ssl-cert cpio
RUN dpkg -i /root/postfix_3.0.4-5ubuntu1_amd64.deb && \
rm /root/postfix_3.0.4-5ubuntu1_amd64.deb
RUN postconf smtputf8_enable=yes && \
postconf smtpd_use_tls=no && \
postconf smtpd_banner='$myhostname ESMTP $mail_name (EAI)' && \
postconf virtual_mailbox_base=/var/mail/vhosts && \
true
RUN apt-get -y install rsyslog
VOLUME /etc/postfix/tables
VOLUME /var/mail/vhosts
EXPOSE 25
RUN rm -rf /var/lib/apt/lists/*
COPY undaemonize.sh /root/
CMD /bin/bash root/undaemonize.sh
#! /usr/bin/env bash
set -eu
# Env. vars
VTABLE=${VTABLE:-/etc/postfix/tables/virtual}
USERID=${USERID:-5000}
GROUPID=${GROUPID:-5000}
# Setup
ln -sf "$VTABLE" /etc/postfix/virtual
postconf virtual_mailbox_maps=hash:/etc/postfix/virtual
postconf virtual_uid_maps=static:$USERID
postconf virtual_gid_maps=static:$GROUPID
postmap -op hash:/etc/postfix/virtual
/etc/init.d/rsyslog start
pidfile="/var/spool/postfix/pid/master.pid"
postfix="/usr/sbin/postfix"
# Proxy signals
function kill_app() {
$postfix stop
exit 0 # exit okay
}
trap "kill_app" SIGINT SIGTERM
# Launch daemon
$postfix start -w
# Show the log, following through file changes
tail -F /var/log/mail.log
exit 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment