Skip to content

Commit 12fb065

Browse files
authored
SYS-656 dovecot 2.4.1 image update (#256)
1 parent bf3bd2a commit 12fb065

11 files changed

Lines changed: 90 additions & 130 deletions

File tree

images/dovecot/Dockerfile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM instantlinux/postfix:3.10.2-r0
1+
FROM instantlinux/postfix:3.10.5-r0
22

33
ARG BUILD_DATE
44
ARG VCS_REF
@@ -9,20 +9,32 @@ LABEL org.opencontainers.image.authors="Rich Braun docker@instantlinux.net" \
99
org.label-schema.vcs-url=https://github.com/instantlinux/docker-tools
1010

1111
ARG DOVECOT_VERSION=2.4.1-r2
12+
ARG PROCMAIL_VERSION=3.22-r4
1213
ARG MKCERT_SHA=d1efad065f9ef34da372847ff4a4d5ffd86b97410b303d8a43ea25aa2119c86d
13-
14+
ARG PROCMAIL_SHA=4ac9f21c3d7dbed5b32e7547da39f4d429de480679b4c856026caea39ca842f9
15+
ARG TARGETPLATFORM
1416
ENV LDAP_SECRETNAME=ldap-ro-password \
1517
SSL_DH=
1618

17-
# TODO - procmail is missing from 3.12 repo, unsure if support ended
18-
RUN echo '@old http://dl-cdn.alpinelinux.org/alpine/v3.11/main' \
19-
>>/etc/apk/repositories && \
20-
apk add --no-cache dovecot=$DOVECOT_VERSION dovecot-ldap=$DOVECOT_VERSION \
21-
procmail@old && \
19+
RUN cd /tmp && \
20+
case ${TARGETPLATFORM} in \
21+
linux/amd64) \
22+
wget -q https://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/procmail-$PROCMAIL_VERSION.apk && \
23+
echo "$PROCMAIL_SHA procmail-$PROCMAIL_VERSION.apk" | sha256sum -c ;; \
24+
linux/arm64) \
25+
wget -q https://dl-cdn.alpinelinux.org/alpine/v3.11/main/aarch64/procmail-$PROCMAIL_VERSION.apk ;; \
26+
linux/arm/v6) \
27+
wget -q https://dl-cdn.alpinelinux.org/alpine/v3.11/main/armhf/procmail-$PROCMAIL_VERSION.apk ;; \
28+
linux/arm/v7) \
29+
wget -q https://dl-cdn.alpinelinux.org/alpine/v3.11/main/armv7/procmail-$PROCMAIL_VERSION.apk ;; \
30+
*) echo Unrecognized ${TARGETPLATFORM} ;; \
31+
esac && \
32+
apk add --no-cache dovecot=$DOVECOT_VERSION dovecot-ldap=$DOVECOT_VERSION && \
33+
apk add --allow-untrusted procmail-$PROCMAIL_VERSION.apk && \
2234
cd /usr/local/bin && \
2335
wget -q https://raw.githubusercontent.com/dovecot/core/release-2.4.1/doc/mkcert.sh && \
2436
echo "$MKCERT_SHA mkcert.sh" | sha256sum -c && \
25-
chmod 755 /usr/local/bin/mkcert.sh
37+
rm /tmp/* && chmod 755 /usr/local/bin/mkcert.sh
2638

2739
EXPOSE 143 993
2840
VOLUME /etc/dovecot/conf.local /home /var/spool/mail

images/dovecot/README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Configuration is defined as files in a volume mounted as
1111

1212
* Define your local settings as dovecot.conf.
1313

14-
* If you have an LDAP server, put its settings in dovecot-ldap.conf. The helm chart provided here can support either Active Directory or openldap.
14+
* If you have an LDAP server, put its settings in passdb section of dovecot.conf. The helm chart provided here can support either Active Directory or openldap.
1515

1616
* (Optional, to save startup time) generate a dh.pem file for TLS:
1717
```
@@ -39,6 +39,14 @@ make dovecot
3939

4040
See the Makefile and Makefile.vars files under k8s directory for default values referenced within kubernetes.yaml.
4141

42+
To provide high availability across the cluster, the helm chart here includes an optional data-sync service to keep the inbox, mail and spool directories synchronized across 2 or more worker nodes. Minor data loss can occur when the service shifts from one worker to another, so this feature isn't recommended for large production deployments (when running on a cloud provider, simply use their block storage capabilities). That said, unison-based data-sync service has been rock-solid on a bare-metal cluster for years.
43+
44+
Auth is the most challenging aspect of implementing dovecot. Use the following command from with the container to verify user authentication:
45+
```
46+
doveadm auth login <user>
47+
```
48+
If using openldap, turn on log setting `BER` to view raw packet contents as you troubleshoot login from dovecot.
49+
4250
### Variables
4351

4452
| Variable | Default | Description |
@@ -47,7 +55,7 @@ See the Makefile and Makefile.vars files under k8s directory for default values
4755
| SSL_DH | | Filename (in conf.local) of DH parameters |
4856
| TZ | UTC | time zone |
4957

50-
Need more configurability? Edit the ConfigMap defined in kubernetes.yaml.
58+
Need more configurability? Edit the ConfigMap defined in the helm chart.
5159

5260
### Secrets
5361

@@ -65,3 +73,21 @@ If you want to make improvements to this image, see [CONTRIBUTING](https://githu
6573
### Upgrade Notes
6674

6775
* When upgrading to 2.3.14+, replace any references to `hash:` with `lmdb:` in your config files.
76+
77+
* When upgrading to 2.4+, there are a lot of gratuitous [config-directive changes](https://doc.dovecot.org/main/installation/upgrade/2.3-to-2.4.html). The Docker image doesn't contain configs but the helm chart provided here has a configmap template that contains the following changes:
78+
79+
|Helm var|2.3|2.4|Notes|
80+
|uris|hosts | ldap_uris | <host> becomes ldap://<host>:389 |
81+
| |ldap_version| (unchanged)| |
82+
|base|base| ldap_base| |
83+
|bind|auth_bind| ldap_bind | |
84+
|bind_userdn|auth_bind_userdn|ldap_bind_userdn | |
85+
|tls|tls|ldap_starttls | |
86+
| | |dovecot_config_version|new|
87+
| | |dovecot_storage_version|new|
88+
|filter| |ldap_filter|now required|
89+
| |args|(removed)|directives moved to passdb config|
90+
| |address|listen| |
91+
| |ssl_cert|ssl_server_cert_file|angle bracket removed|
92+
| |ssl_dh|ssl_server_dh_file|angle bracket removed|
93+
| |ssl_key|ssl_server_key_file|angle bracket removed|

images/dovecot/entrypoint-dovecot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ if [ -s $ETC/conf.local/dovecot.conf ]; then
2727
fi
2828
if [ -z "$SSH_DH" ]; then
2929
openssl dhparam -dsaparam -out $ETC/dh.pem 4096
30-
echo "ssl_dh = <$ETC/dh.pem" >> $ETC/dovecot.conf
30+
echo "ssl_server_dh_file = $ETC/dh.pem" >> $ETC/dovecot.conf
3131
else
32-
echo "ssl_dh = <$ETC/conf.local/$SSH_DH" >> $ETC/dovecot.conf
32+
echo "ssl_server_dh_file = $ETC/conf.local/$SSH_DH" >> $ETC/dovecot.conf
3333
fi
3434
if [ -s $ETC/conf.local/dovecot-ldap.conf ]; then
3535
cp $ETC/conf.local/dovecot-ldap.conf $ETC

images/dovecot/helm/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ sources:
66
- https://github.com/instantlinux/docker-tools
77
- https://github.com/vdukhovni/dovecot
88
type: application
9-
version: 0.1.12
10-
# appVersion: "2.4.1-r2"
11-
appVersion: "2.3.21.1-r0"
9+
version: 0.1.13
10+
appVersion: "2.4.1-r2"
1211
dependencies:
1312
- name: chartlib
1413
version: 0.1.8
1514
repository: https://instantlinux.github.io/docker-tools
1615
- name: data-sync
1716
version: 0.1.3
1817
repository: https://instantlinux.github.io/docker-tools
18+
condition: data-sync.enabled

images/dovecot/helm/templates/configmap.yaml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ metadata:
77
{{- include "local.labels" . | nindent 4 }}
88
data:
99
dovecot.conf: |
10-
dovecot_config_version = 2.4
10+
dovecot_config_version = {{ .Values.version.config }}
11+
dovecot_storage_version = {{ .Values.version.storage }}
1112
auth_mechanisms = plain login
1213
auth_allow_cleartext = no
1314
mail_access_groups = mail
@@ -19,12 +20,29 @@ data:
1920
mail_debug = no
2021
2122
first_valid_uid = 300
22-
passdb dovecot {
23+
passdb ldap {
2324
driver = ldap
24-
args = /etc/dovecot/dovecot-ldap.conf
25+
ldap_uris = {{ .Values.ldap.uris }}
26+
{{- if .Values.ldap.dn }}
27+
ldap_dn = {{ .Values.ldap.dn }}
28+
ldap_dnpass = PASSWORD
29+
{{- end }}
30+
ldap_version = {{ .Values.ldap.version }}
31+
ldap_base = {{ .Values.ldap.base }}
32+
ldap_bind = {{ .Values.ldap.bind }}
33+
ldap_filter = {{ .Values.ldap.filter }}
34+
{{- if .Values.ldap.bind_userdn }}
35+
ldap_bind_userdn = {{ .Values.ldap.bind_userdn }}
36+
{{- end }}
37+
{{- if .Values.ldap.active_directory }}
38+
ldap_user_attrs = sAMAccountName=home=/home/%$
39+
ldap_user_filter = (&(ObjectClass=user)(sAMAccountName=%{user}))
40+
ldap_pass_filter = (&(ObjectClass=user)(sAMAccountName=%{user}))
41+
{{- end }}
42+
ldap_starttls = {{ .Values.ldap.tls }}
2543
}
26-
userdb dovecot {
27-
driver = passwd
44+
userdb passwd {
45+
use_worker = yes
2846
}
2947
service auth {
3048
user = root
@@ -36,33 +54,13 @@ data:
3654
}
3755
service imap-login {
3856
inet_listener imaps {
39-
address = 0.0.0.0
57+
listen = 0.0.0.0
4058
port = 993
4159
ssl = yes
4260
}
4361
}
44-
# ssl_cert = </etc/ssl/certs/smtpd-cert.pem
45-
# ssl_key = </etc/ssl/private/smtpd-key.pem
4662
ssl_min_protocol = TLSv1.2
4763
ssl_server_cert_file = /etc/ssl/certs/smtpd-cert.pem
4864
ssl_server_key_file = /etc/ssl/private/smtpd-key.pem
4965
syslog_facility = "local1"
50-
dovecot-ldap.conf: |
51-
hosts = {{ .Values.ldap.hosts }}
52-
{{- if .Values.ldap.dn }}
53-
dn = {{ .Values.ldap.dn }}
54-
dnpass = PASSWORD
55-
{{- end }}
56-
ldap_version = {{ .Values.ldap.version }}
57-
base = {{ .Values.ldap.base }}
58-
auth_bind = {{ .Values.ldap.auth_bind }}
59-
{{- if .Values.ldap.auth_bind_userdn }}
60-
auth_bind_userdn = {{ .Values.ldap.auth_bind_userdn }}
61-
{{- end }}
62-
{{- if .Values.ldap.active_directory }}
63-
user_attrs = sAMAccountName=home=/home/%$
64-
user_filter = (&(ObjectClass=user)(sAMAccountName=%u))
65-
pass_filter = (&(ObjectClass=user)(sAMAccountName=%u))
66-
{{- end }}
67-
tls = {{ .Values.ldap.tls }}
6866
{{- end }}

images/dovecot/helm/values.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,19 @@ aliases: |
6464
gnats-admin: root
6565
mailman: root
6666
mailman-owner: mailman
67+
configVersion: 2.4.1
6768
dhcpSubnet1: 192.168.2.0/24
6869
domain: example.com
6970
hostnameEmail: example.com
7071
ldap:
7172
active_directory: false
72-
auth_bind: "yes"
73-
auth_bind_userdn: ""
7473
base: cn=Users,DC=workgroup,DC=example,DC=com
74+
bind: "yes"
75+
bind_userdn: ""
7576
dn: ""
76-
hosts: dc01 dc02
77+
filter: (&(objectClass=inetOrgPerson)(uid=%{user}))
7778
tls: "no"
79+
uris: ldap://dc01:389
7880
version: 3
7981
# Force reload of certs at least every 30 days
8082
livenessProbe:
@@ -96,6 +98,9 @@ users: {}
9698
# - username: user2
9799
# name: John Doe
98100
# uid: 301
101+
version:
102+
config: 2.4.1
103+
storage: 2.4.1
99104

100105
deployment:
101106
command: [/bin/sh]
@@ -189,6 +194,7 @@ configmapPostfix:
189194

190195
# Subchart data-sync, maintains persistent data across nodes
191196
data-sync:
197+
enabled: false
192198
statefulset:
193199
containerPorts: [ containerPort: 22 ]
194200
env:

k8s/Makefile.helm

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,27 @@ helm_list:
1212
@helm list --time-format="Mon Jan 2 15:04" --all-namespaces \
1313
--kube-context=sudo
1414

15-
# TODO get rid of global.yaml and values.yaml, the idea made sense before
16-
# adopting helm when values were from environment variables but makes no
17-
# sense with per-instance yaml override files; helm's developers explicitly
18-
# exclude the possibility of reading env vars from the shell enviroment
19-
# in which helm is running - so global is leftover from my decade-earlier
20-
# LXC-era designs
21-
$(CHARTS):: %: ../admin/services/values.yaml helm/%/Chart.lock
15+
$(CHARTS):: %: helm/%/Chart.lock
2216
@echo --$(NOTICE) $@--
2317
ifeq ($(ACTION), delete)
2418
@helm uninstall --kube-context=sudo -n $(K8S_NAMESPACE) $@
2519
else
2620
@$(eval OVERRIDE := $(shell [ -s ../admin/services/values/$@.yaml ] \
2721
&& echo "-f ../admin/services/values/$@.yaml"))
28-
helm upgrade --install -f global.yaml -f $< $(OVERRIDE) $(XARGS) $@ ./helm/$@
22+
helm upgrade --install -f $< $(OVERRIDE) $(XARGS) $@ ./helm/$@
2923
endif
3024
@helm list --time-format="Mon Jan 2 15:04" --selector name=$@
3125

3226
# TODO this is identical to above but for subdir, DRY it out
3327
# the helmify project is just too exhausting
34-
$(INSTANCES):: %: ../admin/services/values.yaml helm/instances/%/Chart.lock
28+
$(INSTANCES):: %: helm/instances/%/Chart.lock
3529
@echo --$(NOTICE) $@--
3630
ifeq ($(ACTION), delete)
3731
@helm uninstall --kube-context=sudo -n $(K8S_NAMESPACE) $@
3832
else
3933
@$(eval OVERRIDE := $(shell [ -s ../admin/services/values/$@.yaml ] \
4034
&& echo "-f ../admin/services/values/$@.yaml"))
41-
helm upgrade --install -f global.yaml -f $< $(OVERRIDE) $(XARGS) $@ ./helm/instances/$@
35+
helm upgrade --install -f $< $(OVERRIDE) $(XARGS) $@ ./helm/instances/$@
4236
endif
4337
@helm list --time-format="Mon Jan 2 15:04" --selector name=$@
4438

k8s/Makefile.vars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ export TZ ?= UTC
3232
export K8S_INGRESS_NGINX_IP ?= 10.101.1.2
3333
export AUTHELIA_IP ?= 10.101.1.5
3434
export MONITOR_EXT_IP ?= 192.168.1.20
35-
# export PROMETHEUS_IP ?= 10.101.1.21
36-
# export PROM_ALERT_IP ?= 10.101.1.22
3735
export RSYSLOGD_IP ?= 10.101.1.40
3836
export COREDNS_IP ?= 10.96.0.10
3937
export NODE_LOCAL_DNS_IP ?= 169.254.0.10

k8s/global.yaml

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

k8s/install/gitlab-rbac.yaml

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

0 commit comments

Comments
 (0)