FROM        ghcr.io/stalwartlabs/mail-server:latest

LABEL       author="RefoselTeam" maintainer="admin@refoseltw.ru"

LABEL       org.opencontainers.image.source="https://gitea.refoseltw.ru/RefoselTeamWork/yolks"
LABEL       org.opencontainers.image.licenses=MIT

ENV         DEBIAN_FRONTEND=noninteractive

# Install additional tools
RUN         apt update \
            && apt upgrade -y \
            && apt install -y \
                curl \
                git \
                tini \
            && apt clean \
            && rm -rf /var/lib/apt/lists/*

# Create directories
RUN         mkdir -p /home/container/stalwart-mail/data \
            && mkdir -p /home/container/stalwart-mail/certs \
            && mkdir -p /home/container/stalwart-mail/logs

EXPOSE      8080 465 587 993 995 4190

STOPSIGNAL  SIGINT

COPY        --chown=root:root ./entrypoint.sh /entrypoint.sh
COPY        --chown=root:root ./config.toml /entrypoint-config.toml
RUN         chmod +x /entrypoint.sh

ENTRYPOINT  ["/usr/bin/tini", "-g", "--"]
CMD         ["/entrypoint.sh"]
