Skip to content

Commit 3e9428c

Browse files
authored
Feature/dockerize mta (#24)
* MTA: use dockerize for configuration * MTA: move entrypoint script * Added some environment variables * MTA: Add mem_limit * MTA: add healthcheck * Web: wait for external hosts * Web: Update roundcube to 1.2.4 * Web: Move support url * Test: use dockerize to wait for other containers
1 parent 0337080 commit 3e9428c

20 files changed

+100
-86
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ up: build
2020
run-test: env clean build
2121
$(compose-test) build
2222
$(compose-production) up -d
23-
sleep 60
2423
$(compose-test) run --rm test /opt/tests/run-tests.sh
2524

2625
.PHONY: clean
@@ -34,4 +33,7 @@ env:
3433

3534
.PHONY: logs
3635
logs:
37-
$(compose-production) logs
36+
$(compose-production) logs mta
37+
$(compose-production) logs mda
38+
$(compose-production) logs web
39+
$(compose-production) logs db

docker-compose.yml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ services:
66
build: ./db
77
restart: on-failure:5
88
env_file: .env
9-
read_only: true
10-
tmpfs:
11-
- /tmp
129
volumes:
1310
- data-db:/var/lib/mysql
1411

@@ -17,14 +14,9 @@ services:
1714
build: ./mta
1815
restart: on-failure:5
1916
env_file: .env
20-
tmpfs:
21-
- /tmp
22-
links:
23-
- db
24-
- mda
25-
- spamassassin
2617
volumes:
2718
- data-tls:/media/tls:ro
19+
mem_limit: 128M
2820

2921
mda:
3022
image: jeboehm/mailserver-mda:latest
@@ -41,22 +33,11 @@ services:
4133
build: ./web
4234
restart: on-failure:5
4335
env_file: .env
44-
read_only: true
45-
tmpfs:
46-
- /tmp
47-
links:
48-
- db
49-
- mda
50-
- mta
5136

5237
spamassassin:
5338
image: jeboehm/mailserver-spamassassin:latest
5439
build: ./spamassassin
5540
restart: on-failure:5
56-
read_only: true
57-
tmpfs:
58-
- /run
59-
- /tmp
6041

6142
volumes:
6243
data-db:

mda/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ ENV MYSQL_HOST=db \
1010
DOCKERIZE_VERSION=v0.5.0 \
1111
SUBMISSION_HOST=mta \
1212
ENABLE_POP3=true \
13-
ENABLE_IMAP=true
13+
ENABLE_IMAP=true \
14+
SSL_CERT=/media/tls/mailserver.crt \
15+
SSL_KEY=/media/tls/mailserver.key
1416

1517
RUN apk --no-cache add \
1618
dovecot \

mda/rootfs/usr/local/bin/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
if ! [ -r /media/tls/mailserver.crt ]
2+
if ! [ -r ${SSL_CERT} ]
33
then
44
/usr/local/bin/create_tls.sh
55
fi

mta/Dockerfile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ ENV MAILNAME=mail.example.com \
99
MYSQL_DATABASE=mailserver \
1010
GREYLISTING_ENABLED=true \
1111
GREYLISTING_DELAY=50 \
12-
FILTER_MIME=false
12+
FILTER_MIME=false \
13+
DOCKERIZE_VERSION=v0.5.0 \
14+
SPAMASSASSIN_HOST=spamassassin \
15+
MDA_HOST=mda \
16+
MTA_HOST=mta \
17+
SSL_CERT=/media/tls/mailserver.crt \
18+
SSL_KEY=/media/tls/mailserver.key
1319

1420
RUN apk --no-cache add \
21+
openssl \
1522
postfix-mysql \
1623
postfix \
1724
postgrey \
@@ -21,29 +28,31 @@ RUN apk --no-cache add \
2128
postconf virtual_mailbox_maps=mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf && \
2229
postconf virtual_alias_maps=mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf && \
2330
postconf smtputf8_enable=no && \
24-
postconf smtpd_milters=inet:spamassassin:9999 && \
31+
postconf smtpd_milters=inet:${SPAMASSASSIN_HOST}:9999 && \
2532
postconf milter_protocol=6 && \
2633
postconf milter_connect_macros="i j {daemon_name} v {if_name} _" && \
27-
postconf virtual_transport=lmtp:mda:2003 && \
28-
postconf smtpd_sasl_path=inet:mda:9000 && \
34+
postconf virtual_transport=lmtp:${MDA_HOST}:2003 && \
35+
postconf smtpd_sasl_path=inet:${MDA_HOST}:9000 && \
2936
postconf smtpd_sasl_type=dovecot && \
3037
postconf smtpd_sasl_auth_enable=yes && \
3138
postconf smtpd_tls_security_level=may && \
3239
postconf smtpd_tls_auth_only=yes && \
33-
postconf smtpd_tls_cert_file=/media/tls/mailserver.crt && \
34-
postconf smtpd_tls_key_file=/media/tls/mailserver.key && \
40+
postconf smtpd_tls_cert_file=${SSL_CERT} && \
41+
postconf smtpd_tls_key_file=${SSL_KEY} && \
3542
postconf soft_bounce=no && \
3643
postconf message_size_limit=50000000 && \
3744
postconf mailbox_size_limit=0 && \
3845
postconf recipient_delimiter=- && \
3946
postconf mynetworks="$MYNETWORKS" && \
4047
newaliases && \
41-
rm -rf /var/run && \
42-
ln -sf /tmp /var/run
48+
wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
49+
tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
50+
rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
4351

4452
COPY rootfs/ /
4553

4654
EXPOSE 25
4755
VOLUME ["/var/spool/postfix"]
4856

49-
CMD ["/entrypoint.sh"]
57+
HEALTHCHECK CMD postfix status || exit 1
58+
CMD ["/usr/local/bin/entrypoint.sh"]

mta/rootfs/entrypoint.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

mta/rootfs/etc/postfix/mysql-email2email.cf

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
user = {{ .Env.MYSQL_USER }}
2+
password = {{ .Env.MYSQL_PASSWORD }}
3+
hosts = {{ .Env.MYSQL_HOST }}
4+
dbname = {{ .Env.MYSQL_DATABASE }}
5+
query = SELECT email FROM virtual_users WHERE email='%s'

mta/rootfs/etc/postfix/mysql-virtual-alias-maps.cf

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
user = {{ .Env.MYSQL_USER }}
2+
password = {{ .Env.MYSQL_PASSWORD }}
3+
hosts = {{ .Env.MYSQL_HOST }}
4+
dbname = {{ .Env.MYSQL_DATABASE }}
5+
query = SELECT destination FROM virtual_aliases WHERE source='%s'

0 commit comments

Comments
 (0)