2020-10-27 11:21:10 +00:00
|
|
|
FROM debian:buster-slim
|
|
|
|
|
|
|
|
ENV \
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
DOMAINNAME=example.com \
|
|
|
|
MAILNAME=mail \
|
|
|
|
POSTMASTER=postmaster@example.com \
|
|
|
|
SSL_CERT=/etc/ssl/mailserver.crt \
|
|
|
|
SSL_KEY=/etc/ssl/mailserver.key
|
2020-10-31 17:19:13 +00:00
|
|
|
|
|
|
|
# Install packages
|
2020-10-27 11:21:10 +00:00
|
|
|
RUN \
|
|
|
|
apt-get update \
|
|
|
|
&& apt-get upgrade -y \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
postfix \
|
|
|
|
telnet \
|
|
|
|
dovecot-core \
|
|
|
|
dovecot-pop3d \
|
|
|
|
dovecot-imapd \
|
|
|
|
dovecot-lmtpd \
|
|
|
|
supervisor \
|
|
|
|
rsyslog \
|
|
|
|
opendkim \
|
|
|
|
opendkim-tools \
|
2020-10-31 17:19:13 +00:00
|
|
|
openssl \
|
2020-10-27 11:21:10 +00:00
|
|
|
&& apt-get autoclean \
|
|
|
|
&& apt-get autoremove
|
|
|
|
|
2020-10-31 17:19:13 +00:00
|
|
|
# Setup folders and users
|
2020-10-27 11:21:10 +00:00
|
|
|
RUN \
|
|
|
|
rm /etc/postfix/main.cf /etc/postfix/master.cf /etc/dovecot/dovecot.conf /etc/dovecot/conf.d/* /etc/rsyslog.conf /etc/rsyslog.d/* \
|
2020-10-31 17:19:13 +00:00
|
|
|
&& groupadd -g 2222 vmail \
|
|
|
|
&& useradd -d /var/mail -M -s /usr/sbin/nologin -u 2222 -g 2222 vmail \
|
2020-10-27 11:21:10 +00:00
|
|
|
&& usermod -aG vmail postfix \
|
|
|
|
&& usermod -aG vmail dovecot \
|
|
|
|
&& usermod -aG vmail opendkim\
|
|
|
|
&& mkdir -p -m 751 /var/mail/ \
|
|
|
|
&& mkdir -p -m 755 /etc/mail/ \
|
|
|
|
&& mkdir -p -m 755 /etc/ssl/ \
|
|
|
|
&& mkdir -p -m 700 /etc/opendkim/keys \
|
|
|
|
&& chown vmail:vmail /var/mail \
|
|
|
|
&& chown opendkim:opendkim /etc/opendkim/keys
|
|
|
|
|
|
|
|
# Copy config files
|
|
|
|
COPY rootfs/ /
|
|
|
|
|
2020-10-31 17:19:13 +00:00
|
|
|
# Expose ports
|
2020-10-27 11:21:10 +00:00
|
|
|
EXPOSE 25 143 587 993
|
|
|
|
|
2020-10-31 17:19:13 +00:00
|
|
|
# Run start script
|
2020-10-27 11:21:10 +00:00
|
|
|
ENTRYPOINT /usr/bin/start.sh
|