Skip to content

Commit b5f5089

Browse files
committed
feat(mda): upgrade to dovecot 2.4.2, simplified configuration (fixes #649, fixes #668)
1 parent 831ee3c commit b5f5089

File tree

20 files changed

+227
-89
lines changed

20 files changed

+227
-89
lines changed

.github/linters/.dive-ci.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
rules:
2-
# If the efficiency is measured below X%, mark as failed.
3-
# Expressed as a ratio between 0-1.
4-
lowestEfficiency: 0.95
5-
6-
# If the amount of wasted space is at least X or larger than X, mark as failed.
7-
# Expressed in B, KB, MB, and GB.
82
highestWastedBytes: 20MB
9-
10-
# If the amount of wasted space makes up for X% or more of the image, mark as failed.
11-
# Note: the base image layer is NOT included in the total image size.
12-
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
13-
highestUserWastedPercent: 0.20
3+
highestUserWastedPercent: 1
4+
lowestEfficiency: 0

target/mda/Dockerfile

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM dovecot/dovecot:2.4.1-dev@sha256:99f45812578122e62663503f55bd32919e96c7b048349539a8511c3e71c00e3e
1+
FROM alpine:3.23@sha256:865b95f46d98cf867a156fe4a135ad3fe50d2056aa3f25ed31662dff6da4eb62 AS base
22

33
LABEL maintainer="https://github.com/jeboehm/docker-mailserver"
44
LABEL vendor="https://github.com/jeboehm/docker-mailserver"
@@ -15,15 +15,18 @@ ENV MYSQL_HOST=db \
1515
1616
RECIPIENT_DELIMITER=-
1717

18-
USER root
19-
RUN apt-get update && \
20-
apt-get install --no-install-recommends -y curl && \
21-
rm -rf \
22-
/etc/dovecot/conf.d/auth.conf \
23-
/etc/dovecot/conf.d/mail.conf \
24-
/etc/dovecot/conf.d/ssl.conf \
25-
/srv/mail \
26-
/var/lib/apt/lists/*
18+
RUN --mount=type=cache,target=/var/cache/apk \
19+
apk add \
20+
curl \
21+
dovecot \
22+
dovecot-fts-flatcurve \
23+
dovecot-lmtpd \
24+
dovecot-mysql \
25+
dovecot-pigeonhole-plugin \
26+
dovecot-pop3d && \
27+
adduser -DH vmail && \
28+
mkdir -p /srv/vmail && \
29+
chown -R vmail:vmail /srv/vmail
2730

2831
COPY --chown=root:root rootfs/ /
2932

@@ -35,9 +38,22 @@ RUN mv /etc/dovecot/conf.d/10-ssl.conf /tmp/10-ssl.conf && \
3538
USER vmail
3639
WORKDIR /
3740

38-
# 2003: LMTP, 2004: AUTH
39-
EXPOSE 2003 2004
40-
41+
# LMTP
42+
EXPOSE 2003
43+
# AUTH
44+
EXPOSE 2004
45+
# IMAP
46+
EXPOSE 31143
47+
EXPOSE 31993
48+
# POP3
49+
EXPOSE 31110
50+
EXPOSE 31995
51+
# MANAGESIEVE
52+
EXPOSE 4190
53+
# DOVEADM
54+
EXPOSE 8080
55+
56+
VOLUME ["/srv/vmail"]
4157
HEALTHCHECK CMD /usr/local/bin/healthcheck.sh
4258

4359
ENTRYPOINT ["/entrypoint.sh"]

target/mda/rootfs/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ if ! [ -r /etc/dovecot/tls/tls.crt ] || ! [ -r /etc/dovecot/tls/tls.key ]; then
2525
exit 1
2626
fi
2727

28-
exec /usr/bin/tini -- /dovecot/sbin/dovecot -F
28+
exec dovecot -F

target/mda/rootfs/etc/dovecot/conf.d/10-auth.conf

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,26 @@ import_environment {
99
auth_mechanisms = plain login
1010
auth_cache_size = 5M
1111

12-
!include auth-sql.conf.ext
12+
sql_driver = mysql
13+
14+
mysql default {
15+
host = $ENV:MYSQL_HOST
16+
port = $ENV:MYSQL_PORT
17+
user = $ENV:MYSQL_USER
18+
password = $ENV:MYSQL_PASSWORD
19+
dbname = $ENV:MYSQL_DATABASE
20+
option_file = /etc/my.cnf
21+
option_group = client
22+
}
23+
24+
passdb sql {
25+
default_password_scheme = SHA256-CRYPT
26+
query = SELECT mail_users.name AS user, mail_domains.name AS domain, password FROM mail_users JOIN mail_domains ON mail_users.domain_id = mail_domains.id \
27+
WHERE mail_users.name = '%{user|username}' AND mail_domains.name = '%{user|domain}' AND enabled = 1 AND NOT (send_only = 1 AND "%{protocol}" in ('imap', 'pop3'));
28+
}
29+
30+
userdb sql {
31+
query = SELECT concat(quota, 'M') AS quota_storage_size FROM mail_users JOIN mail_domains ON mail_users.domain_id = mail_domains.id \
32+
WHERE mail_users.name = '%{user|username}' AND mail_domains.name = '%{user|domain}';
33+
iterate_query = SELECT mail_users.name AS username, mail_domains.name AS domain FROM mail_users JOIN mail_domains ON mail_users.domain_id = mail_domains.id;
34+
}

target/mda/rootfs/etc/dovecot/conf.d/10-common.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ postmaster_address = $ENV:POSTMASTER
1010
hostname = $ENV:MAILNAME
1111
submission_host = $ENV:MTA_SMTP_ADDRESS
1212
doveadm_api_key = $ENV:DOVEADM_API_KEY
13+
14+
mail_uid = vmail
15+
mail_gid = vmail
16+
17+
default_internal_user = vmail
18+
default_login_user = vmail
19+
default_internal_group = vmail
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mail_plugins {
2+
mail_log = yes
3+
notify = yes
4+
}
5+
6+
log_path = /dev/stdout
7+
mail_log_events = delete undelete expunge save copy mailbox_create mailbox_delete mailbox_rename flag_change
8+
9+
event_exporter log {
10+
format = json
11+
time_format = rfc3339
12+
}

target/mda/rootfs/etc/dovecot/conf.d/10-mail.conf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ mail_home = /srv/vmail/%{user|domain}/%{user|username}
33
mail_path = /srv/vmail/%{user|domain}/%{user|username}/Maildir
44
mailbox_list_layout = maildir++
55
mailbox_list_index = yes
6+
mailbox_list_utf8 = yes
67

7-
namespace inbox {
8-
inbox = yes
9-
}
10-
11-
protocol !indexer-worker {
12-
# mail_vsize_bg_after_count = 100
8+
mail_attribute {
9+
dict file {
10+
path = %{home}/dovecot-attributes
11+
}
1312
}

target/mda/rootfs/etc/dovecot/conf.d/10-master.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import_environment {
66
haproxy_trusted_networks = $ENV:TRUSTED_PROXIES
77

88
service lmtp {
9+
chroot =
10+
911
inet_listener lmtp {
1012
port = 2003
1113
}
@@ -18,6 +20,10 @@ service auth {
1820
}
1921

2022
service imap-login {
23+
process_min_avail = 1
24+
client_limit = 100
25+
chroot =
26+
2127
inet_listener imap {
2228
port = 31143
2329
haproxy = $ENV:MDA_UPSTREAM_PROXY
@@ -30,6 +36,10 @@ service imap-login {
3036
}
3137

3238
service pop3-login {
39+
process_min_avail = 1
40+
client_limit = 100
41+
chroot =
42+
3343
inet_listener pop3 {
3444
port = 31110
3545
haproxy = $ENV:MDA_UPSTREAM_PROXY
@@ -40,3 +50,20 @@ service pop3-login {
4050
haproxy = $ENV:MDA_UPSTREAM_PROXY
4151
}
4252
}
53+
54+
service managesieve-login {
55+
process_min_avail = 1
56+
client_limit = 100
57+
chroot =
58+
59+
inet_listener sieve {
60+
port = 4190
61+
}
62+
}
63+
64+
service doveadm {
65+
inet_listener http {
66+
port = 8080
67+
ssl = yes
68+
}
69+
}

target/mda/rootfs/etc/dovecot/conf.d/10-no-chroot.conf

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

target/mda/rootfs/etc/dovecot/conf.d/15-mailboxes.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
namespace inbox {
2+
inbox = yes
3+
separator = /
4+
25
mailbox Drafts {
36
auto = subscribe
47
special_use = \Drafts

0 commit comments

Comments
 (0)