-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
116 lines (108 loc) · 4.48 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
FROM ubuntu:xenial
MAINTAINER John Paul Alcala [email protected]
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && \
apt-get -y install \
rsyslog \
mail-stack-delivery \
ca-certificates \
opendkim \
opendkim-tools \
dovecot-mysql \
postfix-mysql \
spamass-milter \
pflogsumm \
logwatch \
pyzor \
razor \
libmail-dkim-perl \
clamav-milter \
arj \
bzip2 \
cabextract \
cpio \
file \
gzip \
lzop \
nomarch \
p7zip \
pax \
rpm \
unzip \
zip \
zoo && \
sed -i "s/^exit 101$/exit 0/" /usr/sbin/policy-rc.d && \
rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/tmp/.[!.]* \
/etc/cron.weekly/fstrim
COPY etc/ /etc
COPY var/ /var
# User and directory setup
RUN groupadd -g 5000 vmail && \
useradd -g vmail -u 5000 vmail -d /var/mail/vmail -m && \
usermod -G opendkim postfix && \
usermod -a -G debian-spamd spamass-milter && \
sa-compile && \
spamassassin --lint && \
mkdir -p \
/etc/opendkim \
/var/spool/postfix/opendkim \
/var/spool/postfix/spamassassin \
/var/lib/spamassassin/.spamassassin \
/var/lib/spamassassin/.razor \
/var/lib/spamassassin/.pyzor \
/var/spool/postfix/clamav && \
pyzor --homedir /var/lib/spamassassin/.pyzor discover && \
razor-admin -home=/var/lib/spamassassin/.razor -register && \
razor-admin -home=/var/lib/spamassassin/.razor -create && \
razor-admin -home=/var/lib/spamassassin/.razor -discover && \
echo "razorhome = /var/lib/spamassassin/.razor" >> /var/lib/spamassassin/.razor/razor-agent.conf && \
chown opendkim:opendkim /etc/opendkim && \
chown opendkim:root /var/spool/postfix/opendkim && \
chown debian-spamd:root /var/spool/postfix/spamassassin/ && \
chown -R debian-spamd:debian-spamd /var/lib/spamassassin && \
chown clamav:root /var/spool/postfix/clamav/ && \
chown -R vmail:vmail /var/mail/vmail && \
rm -rf /tmp/* /tmp/.[!.]*
# Main postfix configuration
RUN postconf -e 'mydestination = localhost' && \
postconf -e 'smtpd_banner = $myhostname ESMTP' && \
postconf -e 'smtpd_helo_required = yes' && \
postconf -e 'smtpd_sender_restrictions = reject_unknown_sender_domain, reject_sender_login_mismatch' && \
postconf -e 'smtpd_sender_login_maps = $virtual_mailbox_maps' && \
postconf -e 'unknown_address_reject_code = 550' && \
postconf -e 'unknown_hostname_reject_code = 550' && \
postconf -e 'unknown_client_reject_code = 550' && \
postconf -e 'unverified_recipient_reject_code = 550' && \
postconf -e 'smtpd_tls_ask_ccert = yes' && \
postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt' && \
postconf -e 'smtpd_tls_loglevel = 1' && \
postconf -e 'smtpd_tls_session_cache_timeout = 3600s' && \
postconf -e 'message_size_limit = 30720000' && \
postconf -e 'virtual_transport = dovecot' && \
postconf -e 'dovecot_destination_recipient_limit = 1' && \
postconf -e 'default_destination_concurrency_limit = 5' && \
postconf -e 'disable_vrfy_command = yes' && \
postconf -e 'relay_destination_concurrency_limit = 1' && \
postconf -e 'smtp_tls_note_starttls_offer = yes' && \
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' && \
postconf -e 'milter_default_action = accept' && \
postconf -e 'milter_connect_macros = j {daemon_name} v {if_name} _' && \
postconf -e 'non_smtpd_milters = $smtpd_milters' && \
postconf -e 'smtpd_milters = unix:/spamass/spamass.sock unix:/clamav/clamav-milter.ctl unix:/opendkim/opendkim.sock' && \
postconf -e 'postscreen_greet_action = enforce' && \
postconf -e 'postscreen_dnsbl_action = enforce' && \
postconf -e 'postscreen_access_list = permit_mynetworks' && \
postconf -e 'postscreen_dnsbl_sites = zen.spamhaus.org, b.barracudacentral.org, bl.spamcop.net'
# Run script
COPY postfix.sh /
COPY learnspam.sh /
COPY postfix_report.sh /
VOLUME ["/etc/opendkim", "/etc/ssl/private", "/var/mail", "/var/lib/spamassassin", "/var/lib/dovecot", "/var/lib/clamav", "/var/lib/logrotate", "/var/lib/postfix", "/var/log"]
EXPOSE 25 143 993 587
WORKDIR /
CMD ["/postfix.sh"]