-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdocker-stack.yml
291 lines (267 loc) · 6.18 KB
/
docker-stack.yml
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
version: '3.4'
volumes:
dnscrypt:
dnscrypt-server:
ssl:
nsd:
acme-sh:
acme-acc:
services:
acme:
image: neilpang/acme.sh
command: >
/bin/sh -c "echo \"#!/bin/sh
set -e
# Check if certificate is still valid for the next 30 days, if so exit.
if [ -f /opt/ssl/fullchain.pem ]; then
if openssl x509 -checkend 2592000 -noout -in /opt/ssl/fullchain.pem; then
echo 'Certificate is still valid!'
exit 0
else
echo 'Certificate has expired or will do so within 30 days!'
echo 'Renewing...'
fi
fi
# Grab docker secrets
export CF_Key='$$(cat /run/secrets/CF_Key)'
export CF_Email='$$(cat /run/secrets/CF_Email)'
# Issue Certificates
#### Remember to remove '--staging' in production! ####
# acme.sh
# --issue
# --dns dns_cf
# --dnssleep 60
# --domain '*.seby.io'
# --keylength 4096
# --fullchain-file /opt/ssl/fullchain.pem
# --key-file /opt/ssl/key.pem
# --ca-file /opt/ssl/ca.pem
# --cert-file /opt/ssl/cert.pem
# --reloadcmd 'cat /opt/ssl/key.pem > cat /opt/ssl/fullchain.pem > /opt/ssl/fullchain-key.pem.rsa'
acme.sh
--issue
--dns dns_cf
--dnssleep 60
--domain '*.seby.io'
--keylength ec-384
--fullchain-file /opt/ssl/fullchain-ecc.pem
--key-file /opt/ssl/key-ecc.pem
--ca-file /opt/ssl/ca-ecc.pem
--cert-file /opt/ssl/cert-ecc.pem
--reloadcmd 'cat /opt/ssl/key-ecc.pem > cat /opt/ssl/fullchain-ecc.pem > /opt/ssl/fullchain-key.pem.ecdsa'
\" > start.sh
&& chmod +x start.sh
&& ./start.sh"
deploy:
restart_policy:
condition: on-failure
max_attempts: 2
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
secrets:
- CF_Email
- CF_Key
volumes:
- ssl:/opt/ssl
- acme-sh:/root/.acme.sh
- acme-acc:/acme.sh
acme-daemon:
container_name: acme
image: neilpang/acme.sh
command: daemon
deploy:
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 20
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
secrets:
- CF_Email
- CF_Key
volumes:
- ssl:/opt/ssl
- acme-sh:/root/.acme.sh
- acme-acc:/acme.sh
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DEPLOY_DOCKER_CONTAINER_LABEL=sh.acme.autoload.domain=*.seby.io
- DEPLOY_DOCKER_CONTAINER_KEY_FILE=/opt/ssl/key-ecc.pem
- DEPLOY_DOCKER_CONTAINER_CERT_FILE="/opt/ssl/cert-ecc.pem"
- DEPLOY_DOCKER_CONTAINER_CA_FILE="/opt/ssl/ca-ecc.pem"
- DEPLOY_DOCKER_CONTAINER_FULLCHAIN_FILE="/opt/ssl/fullchain-ecc.pem"
- DEPLOY_DOCKER_CONTAINER_RELOAD_CMD="cat /opt/ssl/key-ecc.pem > cat /opt/ssl/fullchain-ecc.pem > /opt/ssl/fullchain-key.pem.ecdsa; sv restart haproxy"
nsd:
container_name: nsd
build: nsd
image: publicarray/nsd
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 20
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
volumes:
- nsd:/etc/nsd/run
networks:
- nsd-net
unbound:
container_name: unbound
depends_on:
- nsd
build: unbound
image: publicarray/unbound
command: -m -d nsd
deploy:
replicas: 1
resources:
limits:
memory: 260M
restart_policy:
condition: any
delay: 5s
max_attempts: 4
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
ports:
- target: 4949
published: 4949
protocol: tcp
mode: ingress
networks:
- nsd-net
- unbound-net
m13253-doh:
container_name: doh
depends_on:
- unbound
build: m13253-doh
image: publicarray/m13253-doh
command: -d unbound
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
networks:
- unbound-net
# doh-proxy:
# depends_on:
# - unbound
# build: doh-proxy
# image: publicarray/doh-proxy
# command: -d
# deploy:
# replicas: 1
# restart_policy:
# condition: any
# delay: 5s
# networks:
# - unbound-net
haproxy:
container_name: haproxy
depends_on:
- acme
- m13253-doh
- unbound
labels:
- sh.acme.autoload.domain=*.seby.io
build: haproxy
image: publicarray/haproxy
command: -d -r
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 20
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
ports:
- target: 443
published: 443
protocol: tcp
mode: ingress
- target: 853
published: 853
protocol: tcp
mode: ingress
volumes:
- ssl:/opt/ssl
networks:
- haproxy-net
- unbound-net
dnscrypt-server:
depends_on:
- unbound
image: publicarray/dnscrypt-server
command:
- init
- -d unbound
- -N
- dns.seby.io
- -E
- 139.99.222.72:8443
- -A
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 20
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
ports:
- target: 443
published: 8443
protocol: tcp
mode: ingress
- target: 443
published: 8443
protocol: udp
mode: ingress
volumes:
- dnscrypt:/opt/dnscrypt-wrapper
- dnscrypt-server:/opt/encrypted-dns
networks:
- dnscrypt-net
- unbound-net
secrets:
CF_Email:
external: true
CF_Key:
external: true
networks:
dnscrypt-net:
driver: overlay
haproxy-net:
driver: overlay
nsd-net:
driver: overlay
unbound-net:
driver: overlay