# A small Postfix used only by the end-to-end test.
FROM debian:stable-slim
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postfix rsyslog \
 && rm -rf /var/lib/apt/lists/* \
 && groupadd -g 5000 vmail && useradd -u 5000 -g 5000 -d /var/mail/vhosts -s /usr/sbin/nologin vmail \
 && mkdir -p /var/mail/vhosts && chown vmail:vmail /var/mail/vhosts
COPY main.cf.append /tmp/main.cf.append
COPY transport vmailbox /etc/postfix/
COPY rsyslog.conf /etc/rsyslog.conf
COPY entrypoint.sh /entrypoint.sh
RUN cat /tmp/main.cf.append >> /etc/postfix/main.cf \
 # no chroot: the smtp and lmtp clients must resolve docker network names
 && postconf -F '*/*/chroot=n' \
 && chmod 644 /etc/postfix/transport /etc/postfix/vmailbox \
 && chmod +x /entrypoint.sh \
 && postmap /etc/postfix/transport /etc/postfix/vmailbox
EXPOSE 25
# Postfix logs to syslog; the test reads /var/log/mail.log
CMD ["/entrypoint.sh"]
