forked from Codegyre/DockerPostfixDovecot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (40 loc) · 1.82 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM ubuntu
RUN apt-get update
RUN echo "mysql-server mysql-server/root_password password mysqlpswd" | 'debconf-set-selections'
RUN echo "mysql-server mysql-server/root_password_again password mysqlpswd" | 'debconf-set-selections'
RUN echo "postfix postfix/mailname string localhost" | 'debconf-set-selections'
RUN echo "postfix postfix/main_mailer_type string 'Internet Site'" | 'debconf-set-selections'
RUN apt-get install -y rsyslog postfix postfix-mysql dovecot-common dovecot-pop3d dovecot-imapd openssl dovecot-mysql mysql-server
ADD postfix /etc/postfix
ADD dovecot /etc/dovecot
ADD mailschema.sql /
RUN chmod a+r /mailschema.sql
RUN groupadd -g 5000 vmail && \
useradd -g vmail -u 5000 vmail -d /home/vmail -m && \
chgrp postfix /etc/postfix/mysql-*.cf && \
chgrp vmail /etc/dovecot/dovecot.conf && \
chmod g+r /etc/dovecot/dovecot.conf
RUN postconf -e virtual_uid_maps=static:5000 && \
postconf -e virtual_gid_maps=static:5000 && \
postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf && \
postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf && \
postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf && \
postconf -e virtual_transport=dovecot && \
postconf -e dovecot_destination_recipient_limit=1 && \
# specially for docker
postconf -F '*/*/chroot = n'
RUN echo "dovecot unix - n n - - pipe" >> /etc/postfix/master.cf && \
echo ' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}' >> /etc/postfix/master.cf
ADD start.sh /start.sh
# default config
ENV DB_HOST localhost
ENV DB_USER root
# SMTP ports
EXPOSE 25
EXPOSE 587
# POP and IMAP ports
EXPOSE 110
EXPOSE 143
EXPOSE 995
EXPOSE 993
CMD sh start.sh