# =============================================================================
# Postfix + PostgreSQL Relay/MTA Image
#
# A pure SMTP relay/MTA: receives inbound mail and forwards it based on
# PostgreSQL-backed relay_domains/transport_maps lookups, equivalent to the
# Postfix setup described in the SimpleLogin self-hosting documentation
# (https://github.com/simple-login/app). No domain, hostname, or database
# credentials are baked into the image; everything is templated from
# environment variables at container startup. This image has no knowledge
# of what consumes the relayed mail.
# =============================================================================

# POSTFIX_VERSION pins the Debian base image tag (e.g. "12-slim"), which in
# turn pins the postfix/postfix-pgsql package versions available via apt.
ARG POSTFIX_VERSION=12-slim
FROM debian:${POSTFIX_VERSION}

LABEL maintainer="Damien Arnodo"
LABEL description="Postfix SMTP relay/MTA with PostgreSQL-backed relay_domains and transport_maps lookups"

RUN echo "postfix postfix/main_mailer_type select No configuration" | debconf-set-selections \
    && echo "postfix postfix/mailname string localhost" | debconf-set-selections \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        postfix \
        postfix-pgsql \
        gettext-base \
        openssl \
        ca-certificates \
    && rm -rf /var/lib/apt/lists/*

COPY templates/ /etc/postfix/templates/
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

EXPOSE 25

ENTRYPOINT ["docker-entrypoint.sh"]
