forked from xingjiudong/docker-smtp-relay
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
83 lines (72 loc) · 2.88 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
FROM alpine:3.7
ARG POSTFIX_VERSION
ARG RSYSLOG_VERSION
ARG IMAGE_VERSION
ARG BUILD_DATE
ARG VCS_REF
LABEL maintainer="Pierre GINDRAUD <pgindraud@gmail.com>" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.name="SMTP server configured as a email relay" \
org.label-schema.description="This image contains the reliable postfix smtp server configured to be " \
org.label-schema.url="https://github.com/Turgon37/docker-smtp-relay" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.vcs-url="https://github.com/Turgon37/docker-smtp-relay" \
org.label-schema.vendor="Pierre GINDRAUD" \
org.label-schema.version="${IMAGE_VERSION}" \
org.label-schema.schema-version="1.0" \
application.postfix.version="${POSTFIX_VERSION}" \
application.rsyslog.version="${RSYSLOG_VERSION}" \
image.version="${IMAGE_VERSION}"
ENV RELAY_MYDOMAIN=domain.com \
RELAY_MYNETWORKS=127.0.0.0/8 \
RELAY_HOST=[127.0.0.1]:25 \
RELAY_USE_TLS=yes \
RELAY_TLS_VERIFY=may \
RELAY_DOMAINS=\$mydomain \
RELAY_STRICT_SENDER_MYDOMAIN=true \
RELAY_MODE=STRICT
#RELAY_MYHOSTNAME=relay.domain.com
#RELAY_POSTMASTER=postmaster@domain.com
#RELAY_LOGIN=loginname
#RELAY_PASSWORD=xxxxxxxx
#RELAY_TLS_CA=/etc/ssl/ca.crt
# Install dependencies
RUN apk --no-cache add \
cyrus-sasl \
cyrus-sasl-digestmd5 \
cyrus-sasl-crammd5 \
postfix=$POSTFIX_VERSION \
rsyslog=$RSYSLOG_VERSION \
supervisor \
# Configuration of main.cf
&& postconf -e 'notify_classes = bounce, 2bounce, data, delay, policy, protocol, resource, software' \
&& postconf -e 'bounce_notice_recipient = $2bounce_notice_recipient' \
&& postconf -e 'delay_notice_recipient = $2bounce_notice_recipient' \
&& postconf -e 'error_notice_recipient = $2bounce_notice_recipient' \
&& postconf -e 'inet_interfaces = all' \
&& postconf -e 'inet_protocols = all' \
&& postconf -e 'myorigin = $mydomain' \
# SMTPD auth
&& postconf -e 'smtpd_sasl_auth_enable = yes' \
&& postconf -e 'smtpd_sasl_type = cyrus' \
&& postconf -e 'smtpd_sasl_local_domain = $mydomain' \
&& postconf -e 'smtpd_sasl_security_options = noanonymous' \
# Other configurations
&& postconf -e 'smtpd_banner = $myhostname ESMTP $mail_name RELAY' \
&& postconf -e 'smtputf8_enable = no' \
# Configuration of sasl2
&& mkdir -p /etc/sasl2 \
&& echo 'pwcheck_method: auxprop' > /etc/sasl2/smtpd.conf \
&& echo 'auxprop_plugin: sasldb' >> /etc/sasl2/smtpd.conf \
&& echo 'mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5' >> /etc/sasl2/smtpd.conf
# copy local files
COPY root/ /
RUN touch /etc/postfix/aliases \
&& touch /etc/postfix/sender_canonical \
&& mkdir -p /data \
&& ln -s /data/sasldb2 /etc/sasldb2 \
&& chmod +x /start.sh /saslpasswd.sh /listpasswd.sh
EXPOSE 25/tcp
VOLUME ["/data"]
WORKDIR /data
CMD ["/start.sh"]