-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (65 loc) · 2.58 KB
/
Dockerfile
File metadata and controls
77 lines (65 loc) · 2.58 KB
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
FROM golang:1.16 AS postfix_exporter
ENV \
POSTFIX_EXPORTER_VERSION=0.3.0 \
POSTFIX_EXPORTER_CHECKSUM=a0d45f3615d6f24b5532d4048fbb08a248588cac7587279aef1473b6e50b6157
RUN set -x \
&& wget "https://github.com/kumina/postfix_exporter/archive/refs/tags/${POSTFIX_EXPORTER_VERSION}.tar.gz" \
&& echo "${POSTFIX_EXPORTER_CHECKSUM} ${POSTFIX_EXPORTER_VERSION}.tar.gz" > SHA256SUM \
&& ( sha256sum -c SHA256SUM || ( echo "Expected ${POSTFIX_EXPORTER_VERSION}.tar.gz: $(sha256sum ${POSTFIX_EXPORTER_VERSION}.tar.gz)"; exit 1; )) \
&& tar -zxf ${POSTFIX_EXPORTER_VERSION}.tar.gz \
&& cd postfix_exporter-${POSTFIX_EXPORTER_VERSION} \
&& go mod download \
&& go install -tags nosystemd,nodocker \
;
# Debian Trixie
FROM debian:13 AS base
EXPOSE 25 587 2525
# Preselections for installation
RUN set -x \
&& echo mail > /etc/hostname \
&& echo "postfix postfix/main_mailer_type string Internet site" >> preseed.txt \
&& echo "postfix postfix/mailname string mail.example.com" >> preseed.txt \
&& debconf-set-selections preseed.txt && rm preseed.txt \
;
# Install packages
RUN set -x \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends postfix mailutils busybox-syslogd opendkim opendkim-tools libsasl2-modules sasl2-bin curl ssl-cert ca-certificates procps s6 inotify-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
;
# Configure Postfix / dkim
RUN set -x \
&& postconf -e myhostname="localhost" \
&& postconf -e smtpd_banner="\$myhostname ESMTP" \
&& postconf -Me submission/inet="submission inet n - y - - smtpd" \
&& postconf -Me 2525/inet="2525 inet n - y - - smtpd" \
&& cp --remove-destination /usr/share/postfix/makedefs.out /etc/postfix/makedefs.out \
&& rm -f /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem \
&& sed -i -E '/^smtpd_tls_cert_file|^smtpd_tls_key_file/d' /etc/postfix/main.cf \
&& rm -f /etc/opendkim.conf \
&& mkdir /etc/opendkim/ \
;
COPY etc/header_checks /etc/postfix/header_checks
COPY etc/opendkim.conf.sh /etc/
COPY --from=postfix_exporter /go/bin/postfix_exporter /usr/local/bin/postfix_exporter
COPY etc/s6 /etc/s6/
COPY entry.sh /
RUN set -x \
&& chmod 0644 /etc/postfix/header_checks \
;
# Development image
FROM base AS development
# Install packages
RUN set -x \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends bats swaks \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
;
# Postfix SMTP Relay
FROM base AS build
ENTRYPOINT ["/entry.sh"]
CMD ["/usr/bin/s6-svscan", "/etc/s6"]