2015-03-28 14:59:15 +00:00
|
|
|
FROM ubuntu:14.04
|
|
|
|
MAINTAINER Thomas VIAL
|
|
|
|
|
|
|
|
# Packages
|
2015-07-16 17:35:11 +00:00
|
|
|
RUN apt-get update -q --fix-missing
|
2015-03-28 14:59:15 +00:00
|
|
|
RUN apt-get -y upgrade
|
2016-04-07 12:20:51 +00:00
|
|
|
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install vim postfix dovecot-core dovecot-imapd dovecot-pop3d \
|
|
|
|
supervisor gamin amavisd-new spamassassin clamav clamav-daemon libnet-dns-perl libmail-spf-perl \
|
2016-01-20 15:41:34 +00:00
|
|
|
pyzor razor arj bzip2 cabextract cpio file gzip nomarch p7zip pax unzip zip zoo rsyslog mailutils netcat \
|
2016-04-20 08:15:51 +00:00
|
|
|
opendkim opendkim-tools opendmarc curl fail2ban && apt-get autoclean && rm -rf /var/lib/apt/lists/*
|
2015-03-28 14:59:15 +00:00
|
|
|
|
2016-04-07 12:20:51 +00:00
|
|
|
# Configures Dovecot
|
|
|
|
RUN sed -i -e 's/include_try \/usr\/share\/dovecot\/protocols\.d/include_try \/etc\/dovecot\/protocols\.d/g' /etc/dovecot/dovecot.conf
|
2016-04-11 22:04:33 +00:00
|
|
|
ADD target/dovecot/auth-passwdfile.inc /etc/dovecot/conf.d/
|
|
|
|
ADD target/dovecot/10-*.conf /etc/dovecot/conf.d/
|
2015-03-29 12:07:56 +00:00
|
|
|
|
2015-03-28 14:59:15 +00:00
|
|
|
# Enables Spamassassin and CRON updates
|
|
|
|
RUN sed -i -r 's/^(CRON|ENABLED)=0/\1=1/g' /etc/default/spamassassin
|
|
|
|
|
|
|
|
# Enables Amavis
|
|
|
|
RUN sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode
|
|
|
|
RUN adduser clamav amavis
|
|
|
|
RUN adduser amavis clamav
|
2015-09-12 08:54:30 +00:00
|
|
|
RUN useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker
|
2015-03-28 14:59:15 +00:00
|
|
|
|
2016-04-17 20:59:35 +00:00
|
|
|
# Configure Fail2ban
|
|
|
|
ADD target/fail2ban/jail.conf /etc/fail2ban/jail.conf
|
2016-04-18 20:57:39 +00:00
|
|
|
ADD target/fail2ban/filters.d/dovecot.conf /etc/fail2ban/filters.d/dovecot.conf
|
|
|
|
RUN echo "ignoreregex =" >> /etc/fail2ban/filter.d/postfix-sasl.conf
|
2016-04-17 20:59:35 +00:00
|
|
|
|
2015-03-28 14:59:15 +00:00
|
|
|
# Enables Clamav
|
2015-07-01 12:10:04 +00:00
|
|
|
RUN chmod 644 /etc/clamav/freshclam.conf
|
2016-04-17 20:59:35 +00:00
|
|
|
RUN (crontab; echo "0 1 * * * /usr/bin/freshclam --quiet") | sort - | uniq - | crontab -
|
2015-03-28 14:59:15 +00:00
|
|
|
RUN freshclam
|
|
|
|
|
2016-01-20 15:41:34 +00:00
|
|
|
# Configure DKIM (opendkim)
|
|
|
|
# DKIM config files
|
2016-04-11 22:04:33 +00:00
|
|
|
ADD target/opendkim/opendkim.conf /etc/opendkim.conf
|
|
|
|
ADD target/opendkim/default-opendkim /etc/default/opendkim
|
2016-01-20 15:41:34 +00:00
|
|
|
|
2016-01-26 17:26:50 +00:00
|
|
|
# Configure DMARC (opendmarc)
|
2016-04-11 22:04:33 +00:00
|
|
|
ADD target/opendmarc/opendmarc.conf /etc/opendmarc.conf
|
|
|
|
ADD target/opendmarc/default-opendmarc /etc/default/opendmarc
|
2016-01-26 17:26:50 +00:00
|
|
|
|
2015-03-31 15:27:54 +00:00
|
|
|
# Configures Postfix
|
2016-04-11 22:04:33 +00:00
|
|
|
ADD target/postfix/main.cf /etc/postfix/main.cf
|
|
|
|
ADD target/postfix/master.cf /etc/postfix/master.cf
|
2016-04-20 21:01:32 +00:00
|
|
|
ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config /usr/local/bin/
|
|
|
|
RUN chmod +x /usr/local/bin/*
|
2015-03-31 15:27:54 +00:00
|
|
|
|
2016-04-18 21:38:52 +00:00
|
|
|
# Configuring Logs
|
|
|
|
RUN sed -i -r "/^#?compress/c\compress\ncopytruncate" /etc/logrotate.conf
|
|
|
|
RUN mkdir -p /var/log/mail && chown syslog:root /var/log/mail
|
|
|
|
RUN touch /var/log/mail/clamav.log && chown -R clamav:root /var/log/mail/clamav.log
|
|
|
|
RUN touch /var/log/mail/freshclam.log && chown -R clamav:root /var/log/mail/freshclam.log
|
|
|
|
RUN sed -i -r 's|/var/log/mail|/var/log/mail/mail|g' /etc/rsyslog.d/50-default.conf
|
|
|
|
RUN sed -i -r 's|LogFile /var/log/clamav/|LogFile /var/log/mail/|g' /etc/clamav/clamd.conf
|
|
|
|
RUN sed -i -r 's|UpdateLogFile /var/log/clamav/|UpdateLogFile /var/log/mail/|g' /etc/clamav/freshclam.conf
|
|
|
|
RUN sed -i -r 's|/var/log/clamav|/var/log/mail|g' /etc/logrotate.d/clamav-daemon
|
|
|
|
RUN sed -i -r 's|/var/log/clamav|/var/log/mail|g' /etc/logrotate.d/clamav-freshclam
|
|
|
|
RUN sed -i -r 's|/var/log/mail|/var/log/mail/mail|g' /etc/logrotate.d/rsyslog
|
|
|
|
|
2016-02-08 22:47:42 +00:00
|
|
|
# Get LetsEncrypt signed certificate
|
2016-04-15 19:02:41 +00:00
|
|
|
RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x1-cross-signed.pem
|
|
|
|
RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem
|
2016-02-08 22:47:42 +00:00
|
|
|
|
2015-03-28 14:59:15 +00:00
|
|
|
# Start-mailserver script
|
2016-04-11 22:04:33 +00:00
|
|
|
ADD target/start-mailserver.sh /usr/local/bin/start-mailserver.sh
|
2015-03-28 14:59:15 +00:00
|
|
|
RUN chmod +x /usr/local/bin/start-mailserver.sh
|
|
|
|
|
2016-01-08 16:52:06 +00:00
|
|
|
# SMTP ports
|
2016-04-15 19:02:41 +00:00
|
|
|
EXPOSE 25 587
|
2016-01-08 16:52:06 +00:00
|
|
|
|
|
|
|
# IMAP ports
|
2016-04-15 19:02:41 +00:00
|
|
|
EXPOSE 143 993
|
2016-01-08 16:52:06 +00:00
|
|
|
|
2016-01-23 22:51:09 +00:00
|
|
|
# POP3 ports
|
2016-04-15 19:02:41 +00:00
|
|
|
EXPOSE 110 995
|
2016-01-23 22:51:09 +00:00
|
|
|
|
2016-01-08 16:52:06 +00:00
|
|
|
CMD /usr/local/bin/start-mailserver.sh
|