mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2025-05-07 20:35:30 +02:00
Merge 8de15b6a57bf03039fdffebfe76713088f9be4bb into 55cfa3049137113ef7925bbad80d735c8d3778d7
This commit is contained in:
commit
6fddc39d6a
113
Dockerfile
113
Dockerfile
@ -1,74 +1,71 @@
|
||||
FROM ubuntu:14.04
|
||||
MAINTAINER Thomas VIAL
|
||||
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
|
||||
|
||||
# Packages
|
||||
RUN apt-get update -q --fix-missing
|
||||
RUN apt-get -y upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install vim postfix sasl2-bin courier-imap courier-imap-ssl \
|
||||
RUN apt-get update && \
|
||||
apt-get upgrade -y --no-install-recommends && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
postfix sasl2-bin libsasl2-modules courier-imap courier-imap-ssl \
|
||||
courier-pop courier-pop-ssl courier-authdaemon supervisor gamin amavisd-new spamassassin clamav clamav-daemon libnet-dns-perl libmail-spf-perl \
|
||||
pyzor razor arj bzip2 cabextract cpio file gzip nomarch p7zip pax unzip zip zoo rsyslog mailutils netcat \
|
||||
opendkim opendkim-tools opendmarc curl fail2ban
|
||||
RUN apt-get autoclean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
|
||||
# Copy configuration files/executables
|
||||
COPY /target /
|
||||
|
||||
|
||||
|
||||
# Configures Saslauthd
|
||||
RUN rm -rf /var/run/saslauthd && ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd
|
||||
RUN adduser postfix sasl
|
||||
RUN echo 'NAME="saslauthd"\nSTART=yes\nMECHANISMS="sasldb"\nTHREADS=0\nPWDIR=/var/spool/postfix/var/run/saslauthd\nPIDFILE="${PWDIR}/saslauthd.pid"\nOPTIONS="-n 0 -c -m /var/spool/postfix/var/run/saslauthd"' > /etc/default/saslauthd
|
||||
RUN rm -rf /var/run/saslauthd && ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd && \
|
||||
adduser postfix sasl && \
|
||||
echo 'NAME="saslauthd"\nSTART=yes\nMECHANISMS="sasldb"\nTHREADS=0\nPWDIR=/var/spool/postfix/var/run/saslauthd\nPIDFILE="${PWDIR}/saslauthd.pid"\nOPTIONS="-n 0 -c -m /var/spool/postfix/var/run/saslauthd"' > /etc/default/saslauthd && \
|
||||
\
|
||||
# Configures Courier \
|
||||
sed -i -r 's/daemons=5/daemons=1/g' /etc/courier/authdaemonrc && \
|
||||
sed -i -r 's/authmodulelist="authpam"/authmodulelist="authuserdb"/g' /etc/courier/authdaemonrc && \
|
||||
\
|
||||
# Enables Spamassassin and CRON updates \
|
||||
sed -i -r 's/^(CRON|ENABLED)=0/\1=1/g' /etc/default/spamassassin && \
|
||||
\
|
||||
# Enables Amavis \
|
||||
sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode && \
|
||||
adduser clamav amavis && \
|
||||
adduser amavis clamav && \
|
||||
useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker && \
|
||||
\
|
||||
# Enables Clamav \
|
||||
chmod 644 /etc/clamav/freshclam.conf && \
|
||||
(crontab -l ; echo "0 1 * * * /usr/bin/freshclam --quiet") | sort - | uniq - | crontab - && \
|
||||
freshclam && \
|
||||
\
|
||||
# Configure DKIM (opendkim) \
|
||||
mkdir -p /etc/opendkim/keys && \
|
||||
chmod +x /usr/local/bin/generate-ssl-certificate && \
|
||||
\
|
||||
# Get LetsEncrypt signed certificate \
|
||||
curl https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x1-cross-signed.pem && \
|
||||
curl https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem && \
|
||||
\
|
||||
# Start-mailserver script \
|
||||
chmod +x /usr/local/bin/start-mailserver.sh && \
|
||||
\
|
||||
# Cleanup
|
||||
apt-get clean && \
|
||||
rm -rf /tmp/* /var/tmp/* && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Configures Courier
|
||||
RUN sed -i -r 's/daemons=5/daemons=1/g' /etc/courier/authdaemonrc
|
||||
RUN sed -i -r 's/authmodulelist="authpam"/authmodulelist="authuserdb"/g' /etc/courier/authdaemonrc
|
||||
|
||||
# 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
|
||||
# SMTP | IMAP | POP3
|
||||
EXPOSE 25 587 143 993 110 995
|
||||
|
||||
# Enables Clamav
|
||||
RUN chmod 644 /etc/clamav/freshclam.conf
|
||||
RUN (crontab -l ; echo "0 1 * * * /usr/bin/freshclam --quiet") | sort - | uniq - | crontab -
|
||||
RUN freshclam
|
||||
|
||||
# Configure DKIM (opendkim)
|
||||
RUN mkdir -p /etc/opendkim/keys
|
||||
ADD postfix/TrustedHosts /etc/opendkim/TrustedHosts
|
||||
# DKIM config files
|
||||
ADD postfix/opendkim.conf /etc/opendkim.conf
|
||||
ADD postfix/default-opendkim /etc/default/opendkim
|
||||
|
||||
# Configure DMARC (opendmarc)
|
||||
ADD postfix/opendmarc.conf /etc/opendmarc.conf
|
||||
ADD postfix/default-opendmarc /etc/default/opendmarc
|
||||
|
||||
# Configures Postfix
|
||||
ADD postfix/main.cf /etc/postfix/main.cf
|
||||
ADD postfix/master.cf /etc/postfix/master.cf
|
||||
ADD postfix/sasl/smtpd.conf /etc/postfix/sasl/smtpd.conf
|
||||
ADD bin/generate-ssl-certificate /usr/local/bin/generate-ssl-certificate
|
||||
RUN chmod +x /usr/local/bin/generate-ssl-certificate
|
||||
|
||||
# Get LetsEncrypt signed certificate
|
||||
RUN curl https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x1-cross-signed.pem
|
||||
RUN curl https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem
|
||||
|
||||
# Start-mailserver script
|
||||
ADD start-mailserver.sh /usr/local/bin/start-mailserver.sh
|
||||
RUN chmod +x /usr/local/bin/start-mailserver.sh
|
||||
|
||||
# SMTP ports
|
||||
EXPOSE 25
|
||||
EXPOSE 587
|
||||
|
||||
# IMAP ports
|
||||
EXPOSE 143
|
||||
EXPOSE 993
|
||||
|
||||
# POP3 ports
|
||||
EXPOSE 110
|
||||
EXPOSE 995
|
||||
|
||||
CMD /usr/local/bin/start-mailserver.sh
|
||||
|
20
Makefile
20
Makefile
@ -7,14 +7,10 @@ build:
|
||||
docker build --no-cache -t $(NAME) .
|
||||
|
||||
run:
|
||||
# Copy test files
|
||||
cp test/accounts.cf postfix/
|
||||
cp test/main.cf postfix/
|
||||
cp test/virtual postfix/
|
||||
# Run containers
|
||||
docker run -d --name mail \
|
||||
-v "`pwd`/postfix":/tmp/postfix \
|
||||
-v "`pwd`/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test/postfix":/tmp/postfix \
|
||||
-v "`pwd`/test/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test":/tmp/test \
|
||||
-e SA_TAG=1.0 \
|
||||
-e SA_TAG2=2.0 \
|
||||
@ -22,14 +18,14 @@ run:
|
||||
-e SASL_PASSWD=testing \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
docker run -d --name mail_pop3 \
|
||||
-v "`pwd`/postfix":/tmp/postfix \
|
||||
-v "`pwd`/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test/postfix":/tmp/postfix \
|
||||
-v "`pwd`/test/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test":/tmp/test \
|
||||
-e ENABLE_POP3=1 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
docker run -d --name mail_smtponly \
|
||||
-v "`pwd`/postfix":/tmp/postfix \
|
||||
-v "`pwd`/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test/postfix":/tmp/postfix \
|
||||
-v "`pwd`/test/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test":/tmp/test \
|
||||
-e SMTP_ONLY=1 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
@ -45,14 +41,12 @@ fixtures:
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/test/email-templates/existing-user.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/test/email-templates/non-existing-user.txt"
|
||||
# Wait for mails to be analyzed
|
||||
sleep 10
|
||||
sleep 30
|
||||
|
||||
tests:
|
||||
# Start tests
|
||||
./test/bats/bats test/tests.bats
|
||||
|
||||
clean:
|
||||
# Get default files back
|
||||
git checkout postfix/accounts.cf postfix/main.cf postfix/virtual
|
||||
# Remove running test containers
|
||||
docker rm -f mail mail_pop3 mail_smtponly
|
||||
|
@ -1 +1,2 @@
|
||||
user@domain.tld|mypassword
|
||||
user1@localhost.localdomain|mypassword
|
||||
user2@otherdomain.tld|mypassword
|
||||
|
@ -1,7 +1,2 @@
|
||||
#
|
||||
# ALIAS => from alias@domain.tld (alias) to user@domain.tld (real account), space separated
|
||||
# alias@domain.tld user@domain.tld
|
||||
#
|
||||
# FORWARD => from redirect@domain.tld to a list of internal/external email addresses, space separated
|
||||
# redirect@domain.tld otheruser@domain.tld otheruser@otherdomain.tld
|
||||
#
|
||||
alias1@localhost.localdomain user1@localhost.localdomain
|
||||
alias2@localhost.localdomain external1@otherdomain.tld
|
||||
|
@ -263,8 +263,8 @@ if [ "$ENABLE_POP3" = 1 -a "$SMTP_ONLY" != 1 ]; then
|
||||
/etc/init.d/courier-pop-ssl start
|
||||
fi
|
||||
|
||||
/etc/init.d/spamassassin start
|
||||
/etc/init.d/clamav-daemon start
|
||||
/etc/init.d/spamassassin start
|
||||
/etc/init.d/amavis start
|
||||
/etc/init.d/opendkim start
|
||||
/etc/init.d/opendmarc start
|
1
test/spamassassin/rules.cf
Normal file
1
test/spamassassin/rules.cf
Normal file
@ -0,0 +1 @@
|
||||
# Place you custom Spamassasin rules here
|
Loading…
Reference in New Issue
Block a user