2015-03-28 14:59:15 +00:00
|
|
|
FROM ubuntu:14.04
|
|
|
|
MAINTAINER Thomas VIAL
|
|
|
|
|
|
|
|
# Packages
|
2016-04-23 10:09:28 +00:00
|
|
|
RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \
|
2016-08-30 07:59:46 +00:00
|
|
|
apt-get -y upgrade && \
|
|
|
|
apt-get -y install --no-install-recommends \
|
|
|
|
amavisd-new \
|
|
|
|
arj \
|
|
|
|
bzip2 \
|
|
|
|
clamav \
|
|
|
|
clamav-daemon \
|
|
|
|
curl \
|
|
|
|
dovecot-core \
|
|
|
|
dovecot-imapd \
|
2016-10-30 13:11:36 +00:00
|
|
|
dovecot-ldap \
|
2016-10-24 13:03:08 +00:00
|
|
|
dovecot-lmtpd \
|
2016-08-30 07:59:46 +00:00
|
|
|
dovecot-managesieved \
|
|
|
|
dovecot-pop3d \
|
|
|
|
dovecot-sieve \
|
|
|
|
ed \
|
|
|
|
fail2ban \
|
|
|
|
fetchmail \
|
|
|
|
file \
|
|
|
|
gamin \
|
|
|
|
gzip \
|
|
|
|
iptables \
|
|
|
|
libmail-spf-perl \
|
|
|
|
libnet-dns-perl \
|
|
|
|
libsasl2-modules \
|
|
|
|
opendkim \
|
|
|
|
opendkim-tools \
|
|
|
|
opendmarc \
|
|
|
|
p7zip \
|
|
|
|
postfix \
|
2016-10-30 13:11:36 +00:00
|
|
|
postfix-ldap \
|
2016-08-30 07:59:46 +00:00
|
|
|
pyzor \
|
|
|
|
razor \
|
|
|
|
rsyslog \
|
2016-10-30 13:11:36 +00:00
|
|
|
sasl2-bin \
|
2016-08-30 07:59:46 +00:00
|
|
|
spamassassin \
|
|
|
|
unzip \
|
|
|
|
&& \
|
|
|
|
curl -sk http://neuro.debian.net/lists/trusty.de-m.libre > /etc/apt/sources.list.d/neurodebian.sources.list && \
|
|
|
|
apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9 && \
|
2016-09-29 20:52:05 +00:00
|
|
|
curl https://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - && \
|
|
|
|
echo "deb http://packages.elastic.co/beats/apt stable main" | tee -a /etc/apt/sources.list.d/beats.list && \
|
|
|
|
apt-get update -q --fix-missing && apt-get -y upgrade fail2ban filebeat && \
|
2016-08-30 07:59:46 +00:00
|
|
|
apt-get autoclean && rm -rf /var/lib/apt/lists/* && \
|
|
|
|
rm -rf /usr/share/locale/* && rm -rf /usr/share/man/* && rm -rf /usr/share/doc/*
|
2015-03-28 14:59:15 +00:00
|
|
|
|
2016-10-08 17:02:47 +00:00
|
|
|
# Enables Clamav
|
|
|
|
RUN (echo "0 0,6,12,18 * * * /usr/bin/freshclam --quiet" ; crontab -l) | crontab -
|
|
|
|
RUN chmod 644 /etc/clamav/freshclam.conf && freshclam
|
|
|
|
|
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-28 06:57:50 +00:00
|
|
|
RUN sed -i -e 's/#mail_plugins = \$mail_plugins/mail_plugins = \$mail_plugins sieve/g' /etc/dovecot/conf.d/15-lda.conf
|
2016-10-30 13:11:36 +00:00
|
|
|
RUN sed -i -e 's/^.*lda_mailbox_autocreate.*/lda_mailbox_autocreate = yes/g' /etc/dovecot/conf.d/15-lda.conf
|
|
|
|
RUN sed -i -e 's/^.*lda_mailbox_autosubscribe.*/lda_mailbox_autosubscribe = yes/g' /etc/dovecot/conf.d/15-lda.conf
|
|
|
|
RUN sed -i -e 's/^.*postmaster_address.*/postmaster_address = '${POSTMASTER_ADDRESS:="postmaster@domain.com"}'/g' /etc/dovecot/conf.d/15-lda.conf
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY target/dovecot/auth-passwdfile.inc /etc/dovecot/conf.d/
|
|
|
|
COPY target/dovecot/??-*.conf /etc/dovecot/conf.d/
|
2015-03-29 12:07:56 +00:00
|
|
|
|
2016-11-13 10:39:45 +00:00
|
|
|
# Configures LDAP
|
|
|
|
COPY target/dovecot/dovecot-ldap.conf.ext /etc/dovecot
|
|
|
|
COPY target/postfix/ldap-users.cf target/postfix/ldap-groups.cf target/postfix/ldap-aliases.cf /etc/postfix/
|
|
|
|
|
2016-09-06 11:06:25 +00:00
|
|
|
# Enables Spamassassin CRON updates
|
|
|
|
RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
2015-03-28 14:59:15 +00:00
|
|
|
|
|
|
|
# Enables Amavis
|
|
|
|
RUN sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode
|
2016-04-24 11:46:48 +00:00
|
|
|
RUN adduser clamav amavis && 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
|
2016-10-08 17:02:47 +00:00
|
|
|
RUN (echo "0 4 * * * find /var/lib/amavis/virusmails/ -type f -mtime +\$VIRUSMAILS_DELETE_DELAY -delete" ; crontab -l) | crontab -
|
2015-03-28 14:59:15 +00:00
|
|
|
|
2016-04-17 20:59:35 +00:00
|
|
|
# Configure Fail2ban
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY target/fail2ban/jail.conf /etc/fail2ban/jail.conf
|
|
|
|
COPY target/fail2ban/filter.d/dovecot.conf /etc/fail2ban/filter.d/dovecot.conf
|
2016-04-23 18:20:25 +00:00
|
|
|
RUN echo "ignoreregex =" >> /etc/fail2ban/filter.d/postfix-sasl.conf
|
2016-04-17 20:59:35 +00:00
|
|
|
|
2016-04-21 16:04:33 +00:00
|
|
|
# Enables Pyzor and Razor
|
|
|
|
USER amavis
|
|
|
|
RUN razor-admin -create && razor-admin -register && pyzor discover
|
|
|
|
USER root
|
|
|
|
|
2016-01-20 15:41:34 +00:00
|
|
|
# Configure DKIM (opendkim)
|
|
|
|
# DKIM config files
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY target/opendkim/opendkim.conf /etc/opendkim.conf
|
|
|
|
COPY 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-09-04 18:37:16 +00:00
|
|
|
COPY target/opendmarc/opendmarc.conf /etc/opendmarc.conf
|
|
|
|
COPY target/opendmarc/default-opendmarc /etc/default/opendmarc
|
2016-10-25 06:57:08 +00:00
|
|
|
COPY target/opendmarc/ignore.hosts /etc/opendmarc/ignore.hosts
|
2016-01-26 17:26:50 +00:00
|
|
|
|
2016-08-21 20:13:13 +00:00
|
|
|
# Configure fetchmail
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general
|
2016-08-21 20:13:13 +00:00
|
|
|
RUN sed -i 's/START_DAEMON=no/START_DAEMON=yes/g' /etc/default/fetchmail
|
|
|
|
|
2015-03-31 15:27:54 +00:00
|
|
|
# Configures Postfix
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/
|
2015-03-31 15:27:54 +00:00
|
|
|
|
2016-04-18 21:38:52 +00:00
|
|
|
# Configuring Logs
|
2016-04-24 11:46:48 +00:00
|
|
|
RUN sed -i -r "/^#?compress/c\compress\ncopytruncate" /etc/logrotate.conf && \
|
|
|
|
mkdir -p /var/log/mail && chown syslog:root /var/log/mail && \
|
|
|
|
touch /var/log/mail/clamav.log && chown -R clamav:root /var/log/mail/clamav.log && \
|
|
|
|
touch /var/log/mail/freshclam.log && chown -R clamav:root /var/log/mail/freshclam.log && \
|
|
|
|
sed -i -r 's|/var/log/mail|/var/log/mail/mail|g' /etc/rsyslog.d/50-default.conf && \
|
2016-09-23 06:22:57 +00:00
|
|
|
sed -i -r 's|;auth,authpriv.none|;mail.none;mail.error;auth,authpriv.none|g' /etc/rsyslog.d/50-default.conf && \
|
2016-04-24 11:46:48 +00:00
|
|
|
sed -i -r 's|LogFile /var/log/clamav/|LogFile /var/log/mail/|g' /etc/clamav/clamd.conf && \
|
|
|
|
sed -i -r 's|UpdateLogFile /var/log/clamav/|UpdateLogFile /var/log/mail/|g' /etc/clamav/freshclam.conf && \
|
|
|
|
sed -i -r 's|/var/log/clamav|/var/log/mail|g' /etc/logrotate.d/clamav-daemon && \
|
|
|
|
sed -i -r 's|/var/log/clamav|/var/log/mail|g' /etc/logrotate.d/clamav-freshclam && \
|
|
|
|
sed -i -r 's|/var/log/mail|/var/log/mail/mail|g' /etc/logrotate.d/rsyslog
|
2016-04-18 21:38:52 +00:00
|
|
|
|
2016-02-08 22:47:42 +00:00
|
|
|
# Get LetsEncrypt signed certificate
|
2016-04-24 11:46:48 +00:00
|
|
|
RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x1-cross-signed.pem && \
|
|
|
|
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
|
|
|
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY ./target/bin /usr/local/bin
|
2015-03-28 14:59:15 +00:00
|
|
|
# Start-mailserver script
|
2016-09-04 18:37:16 +00:00
|
|
|
COPY ./target/start-mailserver.sh /usr/local/bin/
|
2016-04-24 11:46:48 +00:00
|
|
|
RUN chmod +x /usr/local/bin/*
|
2016-01-08 16:52:06 +00:00
|
|
|
|
2016-04-29 13:24:10 +00:00
|
|
|
EXPOSE 25 587 143 993 110 995 4190
|
2016-01-23 22:51:09 +00:00
|
|
|
|
2016-01-08 16:52:06 +00:00
|
|
|
CMD /usr/local/bin/start-mailserver.sh
|
2016-09-29 20:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
ADD target/filebeat.yml.tmpl /etc/filebeat/filebeat.yml.tmpl
|
|
|
|
|
|
|
|
|