-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
260 lines (233 loc) · 7.02 KB
/
docker-compose.yml
File metadata and controls
260 lines (233 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
version: '2.2'
services:
# Generate self-signed certs
# See: https://docker-mailserver.github.io/docker-mailserver/latest/config/security/ssl/#self-signed-certificates
step-ca:
image: smallstep/step-ca:latest
working_dir: /certs
volumes:
- certs:/certs
entrypoint:
- /bin/sh
user: 0:0
command:
- -c
- |
set -eu
if [ ! -d demoCA ]; then
mkdir -p demoCA
step certificate create "Smallstep Root CA" "demoCA/cacert.pem" "demoCA/cakey.pem" \
--no-password --insecure \
--profile root-ca \
--not-before "2021-01-01T00:00:00+00:00" \
--not-after "2031-01-01T00:00:00+00:00" \
--san "example.com" \
--san "mail.example.com" \
--kty RSA --size 2048
step certificate create "Smallstep Leaf" mail.example.com-cert.pem mail.example.com-key.pem \
--no-password --insecure \
--profile leaf \
--ca "demoCA/cacert.pem" \
--ca-key "demoCA/cakey.pem" \
--not-before "2021-01-01T00:00:00+00:00" \
--not-after "2031-01-01T00:00:00+00:00" \
--san "example.com" \
--san "mail.example.com" \
--kty RSA --size 2048
fi
# Mail server
# See: https://docker-mailserver.github.io/docker-mailserver/latest
docker-mailserver:
image: docker.io/mailserver/docker-mailserver:12
domainname: mail.example.com
environment:
- ENABLE_SPAMASSASSIN=0
- ENABLE_CLAMAV=0
- ENABLE_FAIL2BAN=0
- ENABLE_POSTGREY=0
- ENABLE_MANAGESIEVE=1
- ONE_DIR=1
- DMS_DEBUG=0
- POSTFIX_INET_PROTOCOLS=ipv4
- DOVECOT_INET_PROTOCOLS=ipv4
- SSL_TYPE=manual
- SSL_CERT_PATH=/certs/mail.example.com-cert.pem
- SSL_KEY_PATH=/certs/mail.example.com-key.pem
volumes:
- certs:/certs
- dms-mail-data:/var/mail
- dms-mail-state:/var/mail-state
- dms-mail-logs:/var/log/mail
- dms-config:/tmp/docker-mailserver
networks:
default:
aliases:
- example.com
- mail.example.com
- imap.example.com
- smtp.example.com
depends_on:
- step-ca
snappymail:
image: leojonathanoh/snappymail:pr-1
ports:
- 8888:8888
volumes:
- snappymail:/var/lib/snappymail
networks:
- default
isync-imap-to-maildir:
image: theohbrothers/docker-isync:1.4.4
volumes:
- mail:/mail
networks:
- default
depends_on:
- docker-mailserver
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
while ! nc -w 1 -vz imap.example.com 993; do echo "Waiting for docker-mailserver to be up"; sleep 3; done
echo "Getting self-signed certificate"
mbsync-get-cert imap.example.com > /imap.example.com.pem
echo "Creating /mbsyncrc"
cat - > /mbsyncrc <<'EOF'
IMAPStore example-remote
Host imap.example.com
User test@example.com
Pass test
AuthMechs LOGIN
SSLType IMAPS
# Trust our self-signed certificate(s). In production, this may not be needed.
CertificateFile /imap.example.com.pem
# Limit the number of simultaneous IMAP commands
PipelineDepth 30
MaildirStore example-local
SubFolders Verbatim
# The trailing '/' is important for Path
Path /mail/
Inbox /mail/INBOX
Channel example
Far :example-remote:
Near :example-local:
Patterns *
Create Near
Expunge Near
SyncState *
Sync Pull
EOF
echo "Sleeping forever"
exec sleep infinity
isync-maildir-to-imap:
image: theohbrothers/docker-isync:1.4.4
volumes:
- mail2:/mail
networks:
- default
depends_on:
- docker-mailserver
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
while ! nc -w 1 -vz imap.example.com 993; do echo "Waiting for docker-mailserver to be up"; sleep 3; done
echo "Getting self-signed certificate"
mbsync-get-cert imap.example.com > /imap.example.com.pem
echo "Creating /mbsyncrc"
cat - > /mbsyncrc <<'EOF'
IMAPStore example-remote-2
Host imap.example.com
User test2@example.com
Pass test
AuthMechs LOGIN
SSLType IMAPS
# Trust our self-signed certificate(s). In production, this may not be needed.
CertificateFile /imap.example.com.pem
# Limit the number of simultaneous IMAP commands
PipelineDepth 30
MaildirStore example-local
SubFolders Verbatim
# The trailing '/' is important for Path
Path /mail/
Inbox /mail/INBOX
Channel example
Far :example-remote-2:
Near :example-local:
Patterns *
Create Far
Expunge Far
SyncState *
Sync Push
EOF
echo "Sleeping forever"
exec sleep infinity
isync-imap-to-imap:
image: theohbrothers/docker-isync:1.4.4
volumes:
- mbsync:/mbsync # Sync state
networks:
- default
depends_on:
- docker-mailserver
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
while ! nc -w 1 -vz imap.example.com 993; do echo "Waiting for docker-mailserver to be up"; sleep 3; done
echo "Getting self-signed certificate"
mbsync-get-cert imap.example.com > /imap.example.com.pem
echo "Creating /mbsyncrc"
cat - > /mbsyncrc <<'EOF'
IMAPStore example-remote
Host imap.example.com
User test@example.com
Pass test
AuthMechs LOGIN
SSLType IMAPS
# Trust our self-signed certificate(s). In production, this may not be needed.
CertificateFile /imap.example.com.pem
# Limit the number of simultaneous IMAP commands
PipelineDepth 30
IMAPStore example-remote-3
Host imap.example.com
User test3@example.com
Pass test
AuthMechs LOGIN
SSLType IMAPS
# Trust our self-signed certificate(s). In production, this may not be needed.
CertificateFile /imap.example.com.pem
# Limit the number of simultaneous IMAP commands
PipelineDepth 30
Channel example
Far :example-remote:
Near :example-remote-3:
Patterns *
Create Near
Expunge Near
SyncState /mbsync/
Sync Pull
EOF
echo "Sleeping forever"
exec sleep infinity
networks:
default:
volumes:
certs:
dms-mail-data:
dms-mail-state:
dms-mail-logs:
dms-config:
snappymail:
mail:
mail2:
mbsync: