2020-10-27 20:21:10 +09:00
|
|
|
FROM debian:buster-slim
|
|
|
|
|
2020-11-08 02:43:25 +09:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2020-11-01 02:19:13 +09:00
|
|
|
|
|
|
|
# Install packages
|
2020-10-27 20:21:10 +09:00
|
|
|
RUN \
|
|
|
|
apt-get update \
|
|
|
|
&& apt-get upgrade -y \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
dovecot-core \
|
|
|
|
dovecot-imapd \
|
|
|
|
dovecot-lmtpd \
|
2020-11-08 02:43:25 +09:00
|
|
|
dovecot-pop3d \
|
2020-10-27 20:21:10 +09:00
|
|
|
opendkim \
|
|
|
|
opendkim-tools \
|
2020-11-01 02:19:13 +09:00
|
|
|
openssl \
|
2020-11-08 02:43:25 +09:00
|
|
|
postfix \
|
2020-11-23 04:14:59 +09:00
|
|
|
procps \
|
2020-11-08 02:43:25 +09:00
|
|
|
rsyslog \
|
2020-11-23 04:14:59 +09:00
|
|
|
s6 \
|
2020-10-27 20:21:10 +09:00
|
|
|
&& apt-get autoclean \
|
|
|
|
&& apt-get autoremove
|
|
|
|
|
2020-11-01 02:19:13 +09:00
|
|
|
# Setup folders and users
|
2020-10-27 20:21:10 +09:00
|
|
|
RUN \
|
2020-11-08 02:43:25 +09:00
|
|
|
groupadd -g 2222 vmail \
|
2020-11-23 06:45:43 +09:00
|
|
|
&& mkdir -p -m 751 "/var/mail/" \
|
|
|
|
&& mkdir -p -m 755 "/etc/mail/" \
|
|
|
|
&& useradd -d "/var/mail" -M -s "/usr/sbin/nologin" -u 2222 -g 2222 vmail \
|
2020-10-27 20:21:10 +09:00
|
|
|
&& usermod -aG vmail postfix \
|
|
|
|
&& usermod -aG vmail dovecot \
|
|
|
|
&& usermod -aG vmail opendkim\
|
2020-11-23 06:45:43 +09:00
|
|
|
&& chown vmail:vmail "/var/mail"
|
|
|
|
|
2020-10-27 20:21:10 +09:00
|
|
|
# Copy config files
|
|
|
|
COPY rootfs/ /
|
|
|
|
|
2020-11-23 04:14:59 +09:00
|
|
|
RUN \
|
2020-11-23 06:45:43 +09:00
|
|
|
chmod +x "/etc/service/postfix/run" \
|
|
|
|
&& chmod +x "/etc/service/dovecot/run" \
|
|
|
|
&& chmod +x "/etc/service/opendkim/run" \
|
|
|
|
&& chmod +x "/etc/service/rsyslog/run"
|
2020-11-23 04:14:59 +09:00
|
|
|
|
2020-11-23 06:45:43 +09:00
|
|
|
# Prepare user
|
2020-11-23 07:13:47 +09:00
|
|
|
RUN mkdir -p "/var/mail/${DOMAINNAME}" \
|
|
|
|
&& mkdir -p "/var/mail/${DOMAINPART}/${USER%@*}" \
|
2020-11-23 06:45:43 +09:00
|
|
|
&& chown vmail:vmail "/var/mail/${DOMAINNAME}" \
|
2020-11-23 07:13:47 +09:00
|
|
|
&& chown vmail:vmail "/var/mail/${DOMAINPART}/${USER%@*}"
|
2020-11-23 04:14:59 +09:00
|
|
|
|
2020-11-01 02:19:13 +09:00
|
|
|
# Expose ports
|
2020-11-23 04:14:59 +09:00
|
|
|
EXPOSE 25 110 143 587 993 995
|
2020-10-27 20:21:10 +09:00
|
|
|
|
2020-11-01 02:19:13 +09:00
|
|
|
# Run start script
|
2020-10-27 20:21:10 +09:00
|
|
|
ENTRYPOINT /usr/bin/start.sh
|