mirror of
https://github.com/bokysan/docker-postfix.git
synced 2025-09-03 21:14:26 +08:00
Summary ^^^^^^^ This commit refactors the code base to be more manageble and prepares the groundwork for tests. Refactoring ^^^^^^^^^^^ Files are now moved to subdirectories, all for the sole purpose of easier management. Tests live in their own folders, as well as configs and other files. Test framework ^^^^^^^^^^^^^^ Two new important scripts/directories are available: - `unit-tests.sh` / `/unit-test` which executes unit tests across shell scripts, and - `integration-test.sh` / `integration-tests`, which spins up the container and tries to send the email. Both tests use the [BATS](https://github.com/sstephenson/bats) framework for testing. To create a new test, simply drop a `.bats` file into a corresponding directory. Functions have been extracted into `common-run.sh`, to be able to test them independently. DKIM_SELECTOR ^^^^^^^^^^^^^ It is now possible to specify a DKIM selector to use (instead of the default "mail"). See `README.md` for more details. JSON logging ^^^^^^^^^^^^ WIP: rsyslog will now output JSON logs. This is especially important if you plan on deploying the image into Kubernetes, as [Prometheus](https://prometheus.io/) can handle logs in JSON much easier. TODO: Make this an optional feature, to not confuse existing users.
61 lines
2.4 KiB
Docker
61 lines
2.4 KiB
Docker
ARG ALPINE_VERSION=latest
|
|
FROM alpine:${ALPINE_VERSION}
|
|
LABEL maintaner="Bojan Cekrlic - https://github.com/bokysan/docker-postfix/"
|
|
|
|
# See README.md for details
|
|
|
|
# Set the timezone for the container, if needed.
|
|
ENV TZ=
|
|
# Postfix myhostname
|
|
ENV HOSTNAME=
|
|
# Host that relays your msgs
|
|
ENV RELAYHOST=
|
|
# An (optional) username for the relay server
|
|
ENV RELAYHOST_USERNAME=
|
|
# An (optional) login password for the relay server
|
|
ENV RELAYHOST_PASSWORD=
|
|
# Define relay host TLS connection level. See http://www.postfix.org/postconf.5.html#smtp_tls_security_level for details.
|
|
# By default, the permissive level ("may") is used, if not defined.
|
|
ENV RELAYHOST_TLS_LEVEL=
|
|
# Allow domains from per Network ( default 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 )
|
|
ENV MYNETWORKS=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
|
|
# Allow any sender domains
|
|
ENV ALLOWED_SENDER_DOMAINS=
|
|
# Don't allow blank value for ALLOWED_SENDER_DOMAINS
|
|
ENV ALLOW_EMPTY_SENDER_DOMAINS=
|
|
# Attachments size. 0 means unlimited. Usually needs to be set if your relay host has an attachment size limit
|
|
ENV MESSAGE_SIZE_LIMIT=
|
|
# Enable additional debugging for connections to postfix
|
|
ENV INBOUND_DEBUGGING=
|
|
# DKIM domain selector. If not set, the default (mail) will be used
|
|
ENV DKIM_SELECTOR=
|
|
|
|
# Install supervisor, postfix
|
|
# Install postfix first to get the first account (101)
|
|
# Install opendkim second to get the second account (102)
|
|
RUN true && \
|
|
apk add --no-cache --upgrade cyrus-sasl cyrus-sasl-plain cyrus-sasl-login && \
|
|
apk add --no-cache postfix && \
|
|
apk add --no-cache opendkim && \
|
|
apk add --no-cache ca-certificates tzdata supervisor rsyslog && \
|
|
apk add --no-cache --upgrade musl musl-utils && \
|
|
(rm "/tmp/"* 2>/dev/null || true) && (rm -rf /var/cache/apk/* 2>/dev/null || true)
|
|
|
|
# Set up configuration
|
|
COPY /configs/supervisord.conf /etc/supervisord.conf
|
|
COPY /configs/rsyslog.conf /etc/rsyslog.conf
|
|
COPY /configs/opendkim.conf /etc/opendkim/opendkim.conf
|
|
COPY /configs/smtp_header_checks /etc/postfix/smtp_header_checks
|
|
COPY /scripts/*.sh /
|
|
|
|
RUN chmod +x /run.sh /opendkim.sh
|
|
|
|
# Set up volumes
|
|
VOLUME [ "/var/spool/postfix", "/etc/postfix", "/etc/opendkim/keys" ]
|
|
|
|
# Run supervisord
|
|
USER root
|
|
WORKDIR /tmp
|
|
|
|
EXPOSE 587
|
|
CMD ["/bin/sh", "-c", "/run.sh"]
|