2024-01-07 23:51:33 +08:00
|
|
|
# syntax=docker/dockerfile:1.6
|
2022-04-13 15:57:46 +08:00
|
|
|
|
2024-02-25 16:24:13 +08:00
|
|
|
# Note:
|
|
|
|
# The BASE_IMAGE can be changed for this docker image. In fact, it will be. Check .github/workflows/master.yml.
|
|
|
|
# This image is automatically built with Debian, Ubuntu and Alpine as underlying systems. Each of these has its
|
|
|
|
# own advantages and shortcomings. In essence:
|
|
|
|
#
|
|
|
|
# - use Alpine if you're strapped for space. But beware it uses MUSL LIBC, so unicode support might be an issue.
|
|
|
|
# - use Debian if you're interested in the greatest cross-platform compatibility. It is larger than Alpine, though.
|
|
|
|
# - use Ubuntu if, well, Ubuntu is your thing and you're used to Ubuntu ecosystem.
|
2023-10-28 00:53:48 +08:00
|
|
|
ARG BASE_IMAGE=debian:bookworm-slim
|
2020-11-06 17:52:17 +08:00
|
|
|
|
2022-04-13 15:57:46 +08:00
|
|
|
FROM ${BASE_IMAGE} AS build-scripts
|
|
|
|
COPY ./build-scripts ./build-scripts
|
2016-03-18 07:06:12 +08:00
|
|
|
|
2021-09-06 17:25:10 +08:00
|
|
|
# ============================ INSTALL BASIC SERVICES ============================
|
2022-04-13 16:16:42 +08:00
|
|
|
FROM ${BASE_IMAGE} AS base
|
2022-06-09 21:32:07 +08:00
|
|
|
ARG TARGETPLATFORM
|
2021-09-06 17:25:10 +08:00
|
|
|
|
2019-01-02 17:10:17 +08:00
|
|
|
# Install supervisor, postfix
|
2019-02-19 19:08:13 +08:00
|
|
|
# Install postfix first to get the first account (101)
|
|
|
|
# Install opendkim second to get the second account (102)
|
2022-06-09 21:32:07 +08:00
|
|
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=var-cache-apt-$TARGETPLATFORM \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=var-lib-apt-$TARGETPLATFORM \
|
2022-06-16 18:36:30 +08:00
|
|
|
--mount=type=tmpfs,target=/var/cache/apk \
|
2022-04-13 15:57:46 +08:00
|
|
|
--mount=type=tmpfs,target=/tmp \
|
|
|
|
--mount=type=bind,from=build-scripts,source=/build-scripts,target=/build-scripts \
|
|
|
|
sh /build-scripts/postfix-install.sh
|
|
|
|
|
2021-09-06 17:25:10 +08:00
|
|
|
# ============================ BUILD SASL XOAUTH2 ============================
|
2022-04-13 16:16:42 +08:00
|
|
|
FROM base AS sasl
|
2021-09-06 17:25:10 +08:00
|
|
|
|
2022-06-09 21:32:07 +08:00
|
|
|
ARG TARGETPLATFORM
|
2021-09-06 17:25:10 +08:00
|
|
|
ARG SASL_XOAUTH2_REPO_URL=https://github.com/tarickb/sasl-xoauth2.git
|
2023-10-27 15:50:39 +08:00
|
|
|
ARG SASL_XOAUTH2_GIT_REF=release-0.24
|
2022-04-13 15:57:46 +08:00
|
|
|
|
2022-06-16 18:36:30 +08:00
|
|
|
# --mount=type=cache,target=/var/cache/apk,sharing=locked,id=var-cache-apk-$TARGETPLATFORM \
|
|
|
|
# --mount=type=cache,target=/etc/apk/cache,sharing=locked,id=etc-apk-cache-$TARGETPLATFORM \
|
2022-06-09 21:32:07 +08:00
|
|
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=var-cache-apt-$TARGETPLATFORM \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=var-lib-apt-$TARGETPLATFORM \
|
2023-02-09 16:22:59 +08:00
|
|
|
--mount=type=tmpfs,target=/etc/apk/cache \
|
2022-06-16 18:36:30 +08:00
|
|
|
--mount=type=tmpfs,target=/var/cache/apk \
|
2022-04-13 15:57:46 +08:00
|
|
|
--mount=type=tmpfs,target=/tmp \
|
|
|
|
--mount=type=tmpfs,target=/sasl-xoauth2 \
|
|
|
|
--mount=type=bind,from=build-scripts,source=/build-scripts,target=/build-scripts \
|
|
|
|
sh /build-scripts/sasl-build.sh
|
|
|
|
|
2022-04-13 16:16:42 +08:00
|
|
|
# ============================ Prepare main image ============================
|
2022-04-13 15:57:46 +08:00
|
|
|
FROM sasl
|
|
|
|
LABEL maintainer="Bojan Cekrlic - https://github.com/bokysan/docker-postfix/"
|
2020-11-06 17:52:17 +08:00
|
|
|
|
2018-07-27 22:42:35 +08:00
|
|
|
# Set up configuration
|
2020-06-30 00:49:52 +08:00
|
|
|
COPY /configs/supervisord.conf /etc/supervisord.conf
|
2020-07-01 19:50:08 +08:00
|
|
|
COPY /configs/rsyslog*.conf /etc/
|
2020-06-30 00:49:52 +08:00
|
|
|
COPY /configs/opendkim.conf /etc/opendkim/opendkim.conf
|
|
|
|
COPY /configs/smtp_header_checks /etc/postfix/smtp_header_checks
|
2022-08-29 21:44:43 +08:00
|
|
|
COPY /configs/master.cf /etc/postfix/master.cf
|
2021-11-10 21:12:14 +08:00
|
|
|
COPY /scripts/* /scripts/
|
2020-06-30 00:49:52 +08:00
|
|
|
|
2021-11-10 21:12:14 +08:00
|
|
|
RUN chmod +x /scripts/*
|
2016-03-18 07:06:12 +08:00
|
|
|
|
2019-02-19 17:49:55 +08:00
|
|
|
# Set up volumes
|
|
|
|
VOLUME [ "/var/spool/postfix", "/etc/postfix", "/etc/opendkim/keys" ]
|
2016-03-18 07:06:12 +08:00
|
|
|
|
2018-07-27 22:42:35 +08:00
|
|
|
# Run supervisord
|
|
|
|
USER root
|
|
|
|
WORKDIR /tmp
|
|
|
|
|
2024-01-09 17:59:04 +08:00
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=2s --retries=3 CMD /scripts/healthcheck.sh
|
2020-11-03 18:51:51 +08:00
|
|
|
|
2018-07-27 22:42:35 +08:00
|
|
|
EXPOSE 587
|
2021-11-10 21:12:14 +08:00
|
|
|
CMD [ "/bin/sh", "-c", "/scripts/run.sh" ]
|