docker-mailserver/Dockerfile

72 lines
2.7 KiB
Docker
Raw Normal View History

FROM ubuntu:14.04
MAINTAINER Thomas VIAL
# Packages
RUN apt-get update -q --fix-missing
RUN apt-get -y upgrade
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 16:41:34 +01:00
pyzor razor arj bzip2 cabextract cpio file gzip nomarch p7zip pax unzip zip zoo rsyslog mailutils netcat \
2016-04-15 21:02:41 +02:00
opendkim opendkim-tools opendmarc curl fail2ban sasl2-bin
2015-11-20 17:31:47 +01:00
RUN apt-get autoclean && rm -rf /var/lib/apt/lists/*
# 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
ADD target/dovecot/auth-passwdfile.inc /etc/dovecot/conf.d/
ADD target/dovecot/10-*.conf /etc/dovecot/conf.d/
2015-03-29 14:07:56 +02: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
RUN useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker
# Configure Fail2ban
ADD target/fail2ban/jail.conf /etc/fail2ban/jail.conf
2016-04-18 22:57:39 +02:00
ADD target/fail2ban/filters.d/dovecot.conf /etc/fail2ban/filters.d/dovecot.conf
RUN echo "ignoreregex =" >> /etc/fail2ban/filter.d/postfix-sasl.conf
# Enables Clamav
2015-07-01 14:10:04 +02:00
RUN chmod 644 /etc/clamav/freshclam.conf
RUN (crontab; echo "0 1 * * * /usr/bin/freshclam --quiet") | sort - | uniq - | crontab -
RUN freshclam
2016-01-20 16:41:34 +01:00
# Configure DKIM (opendkim)
RUN mkdir -p /etc/opendkim/keys
ADD target/opendkim/TrustedHosts /etc/opendkim/TrustedHosts
2016-01-20 16:41:34 +01:00
# DKIM config files
ADD target/opendkim/opendkim.conf /etc/opendkim.conf
ADD target/opendkim/default-opendkim /etc/default/opendkim
2016-01-20 16:41:34 +01:00
# Configure DMARC (opendmarc)
ADD target/opendmarc/opendmarc.conf /etc/opendmarc.conf
ADD target/opendmarc/default-opendmarc /etc/default/opendmarc
# Configures Postfix
ADD target/postfix/main.cf /etc/postfix/main.cf
ADD target/postfix/master.cf /etc/postfix/master.cf
ADD target/bin/generate-ssl-certificate /usr/local/bin/generate-ssl-certificate
RUN chmod +x /usr/local/bin/generate-ssl-certificate
# Get LetsEncrypt signed certificate
2016-04-15 21:02:41 +02: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
# Start-mailserver script
ADD target/start-mailserver.sh /usr/local/bin/start-mailserver.sh
RUN chmod +x /usr/local/bin/start-mailserver.sh
2016-01-08 17:52:06 +01:00
# SMTP ports
2016-04-15 21:02:41 +02:00
EXPOSE 25 587
2016-01-08 17:52:06 +01:00
# IMAP ports
2016-04-15 21:02:41 +02:00
EXPOSE 143 993
2016-01-08 17:52:06 +01:00
2016-01-23 23:51:09 +01:00
# POP3 ports
2016-04-15 21:02:41 +02:00
EXPOSE 110 995
2016-01-23 23:51:09 +01:00
2016-01-08 17:52:06 +01:00
CMD /usr/local/bin/start-mailserver.sh