-
Notifications
You must be signed in to change notification settings - Fork 27
/
Dockerfile
31 lines (25 loc) · 1 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
FROM alpine:3
EXPOSE 25 80
VOLUME /etc/letsencrypt
# Install system dependencies.
RUN apk add --update --no-cache \
# Postfix itself:
postfix postfix-pgsql \
# To generate Postfix config files:
python3 \
# To generate and renew Postfix TLS certificate:
certbot \
dcron
# Install Python dependencies.
RUN python3 -m ensurepip
RUN pip3 install jinja2
# Copy sources.
ADD generate_config.py /src/
ADD scripts/certbot-renew-crontab.sh /etc/periodic/hourly/renew-postfix-tls
ADD scripts/certbot-renew-posthook.sh /etc/letsencrypt/renewal-hooks/post/reload-postfix.sh
ADD templates /src/templates
# Generate config, ask for a TLS certificate to Let's Encrypt, start Postfix and Cron daemon.
WORKDIR /src
CMD ./generate_config.py --certbot && certbot -n certonly; crond && ./generate_config.py --postfix && postfix start-fg
# Idea taken from https://github.com/Mailu/Mailu/blob/master/core/postfix/Dockerfile
HEALTHCHECK --start-period=350s CMD echo QUIT|nc localhost 25|grep "220 .* ESMTP Postfix"