FROM debian:stable-slim
# FROM bitnami/minideb:latest

LABEL maintainer="Ludovic CANDELLIER <ludo@huma.net>"

# Set Environment Variables
ENV DEBIAN_FRONTEND noninteractive

# Start as root
USER root

# always run apt update when start and after add new source list, then clean up at end.
RUN apt-get update -yqq; \
    apt-get upgrade -yqq; \
    apt-get -yqq install --no-install-recommends apt-utils procps rsyslog apt-transport-https lsb-release ca-certificates curl wget \
    logrotate postfix

COPY ./conf/main.cf /etc/postfix/main.cf

# RUN ln -snf /etc/services /var/spool/postfix/etc/services

COPY run.sh /
RUN chmod +x /run.sh

RUN /etc/init.d/postfix start

# Clean up
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    rm /var/log/lastlog /var/log/faillog

# CMD ["/bin/bash", "/run.sh"]

# Set default work directory
WORKDIR /var

EXPOSE 25
