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 postfix-ldap rsyslog &&\
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN rm -rf /var/log/* &&\
    mkfifo /var/log/mail.info &&\
    ln -s /dev/null /var/log/mail.log &&\
    ln -s /dev/stderr /var/log/mail.err &&\
    ln -s /dev/null /var/log/syslog &&\
    ln -s /dev/null /var/log/messages

COPY ./config/ /etc/postfix/

COPY ./vars-vars /etc/vars-vars

COPY ./vars-files /etc/vars-files

COPY ./run.sh /run.sh

EXPOSE 25 587

CMD ["/run.sh"]

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