FROM debian:jessie

MAINTAINER Robin Thoni <robin@rthoni.com>

RUN groupadd -r email --gid=7788 && useradd -r -g email --uid=7788 email

RUN echo "postfix postfix/main_mailer_type string Internet site" > preseed.txt &&\
    echo "postfix postfix/mailname string mail.example.com" >> preseed.txt

RUN debconf-set-selections preseed.txt

RUN DEBIAN_FRONTEND=noninteractive apt-get update &&\
    apt-get install -y postfix postfix-pgsql rsyslog &&\
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY ./run.sh /run.sh

RUN rm -rf /etc/postfix/*

COPY ./config/ /etc/postfix/

COPY ./certs/ /etc/ssl/private/

EXPOSE 25 587

CMD ["/run.sh"]
