-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdocker-swarm.yml
297 lines (274 loc) · 8.38 KB
/
docker-swarm.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
292
293
294
295
296
297
# environment must be first imported using:
# $ export $(cat .env)
# until .env file is supported (if ever)
version: '3.7'
networks:
traefik-public:
external: true
internal:
driver: overlay
attachable: true
services:
mosquitto:
env_file: .env
image: thinxcloud/mosquitto
ports:
- '1883:1883' # mqtt
- '1884:1883' # mqtts
- '8883:8883' # websocket
restart: unless-stopped
networks:
- nat
- internal
volumes:
- '/mnt/data/mosquitto/config:/etc/mosquitto/config:rw'
- '/mnt/data/mosquitto/config:/mqtt/config:ro'
- '/mnt/data/mosquitto/ssl:/mqtt/ssl:ro'
- '/mnt/data/mosquitto/data:/mqtt/data:rw'
- '/mnt/data/mosquitto/log:/mqtt/log:rw'
- '/mnt/data/mosquitto/auth:/mqtt/auth:rw'
deploy:
resources:
reservations:
cpus: '0.2'
memory: 64M
limits:
cpus: '0.5'
memory: 128M
labels:
- traefik.enable=true
- traefik.backend=mosquitto
- traefik.frontend.entryPoints=mqtt,mqtts
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.services.mosquitto.loadbalancer.server.port=1883
- "swarmpit.service.deployment.autoredeploy=true"
couchdb:
env_file: .env
image: 'couchdb:3.1.0'
healthcheck:
test:
- CMD-SHELL
- 'curl -XGET http://localhost:5984'
interval: 10s
timeout: 50s
retries: 5
environment:
- "NODENAME=${NODENAME}"
- "COUCHDB_ADMIN=${COUCHDB_USER}"
- "COUCHDB_USER=${COUCHDB_USER}"
- "COUCHDB_PASS=${COUCHDB_PASS}"
- "COUCHDB_PASSWORD=${COUCHDB_PASS}"
- "COUCHDB_COOKIE=${COUCHDB_COOKIE}"
- "COUCHDB_SECRET=${COUCHDB_SECRET}"
ports:
- 5984:5984 # not in production!
networks:
- traefik-public # not in production!
# - internal # for production
volumes:
- type: bind
source: /mnt/data/couchdb
target: /opt/couchdb/data
- type: bind
source: /mnt/data
target: /opt/couchdb/etc
# probably deprecated
- type: bind
source: /mnt/data/couchdb
target: /var/lib/couchdb
deploy:
resources:
reservations:
cpus: '1.0'
memory: 512M
limits:
cpus: '1.0'
memory: 1024M
labels:
- "swarmpit.service.deployment.autoredeploy=true"
thinx-redis:
env_file: .env
networks:
- internal
image: thinxcloud/redis
command:
- redis-server
- '--requirepass'
- '${REDIS_PASSWORD}'
- '--port'
- '6379'
environment:
- "ALLOW_EMPTY_PASSWORD=no"
- "REDIS_PASSWORD=${REDIS_PASSWORD}"
- "REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL"
ports:
- 6379
volumes:
- '/mnt/data/thinx/eu/redis:/data'
deploy:
resources:
reservations:
cpus: '0.5'
memory: 32M
limits:
cpus: '1.0'
memory: 512M
labels:
- "swarmpit.service.deployment.autoredeploy=true"
transformer:
env_file: .env
user: transformer
image: thinxcloud/transformer
environment:
- "ROLLBAR_ACCESS_TOKEN=${ROLLBAR_ACCESS_TOKEN}"
- "ROLLBAR_ENVIRONMENT=${ROLLBAR_ENVIRONMENT}"
- "REVISION=2"
networks:
- internal
ports:
- 7474
labels:
- traefik.backend.transformer.noexpose
deploy:
resources:
reservations:
cpus: '0.2'
memory: 256M
limits:
cpus: '1.0'
memory: 256M
labels:
- "swarmpit.service.deployment.autoredeploy=true"
worker:
env_file: .env
image: thinxcloud/worker:latest
environment:
- "ROLLBAR_ACCESS_TOKEN=${ROLLBAR_ACCESS_TOKEN}"
- "ROLLBAR_ENVIRONMENT=${ROLLBAR_ENVIRONMENT}"
- "THINX_SERVER=http://api:4000"
- "WORKER_SECRET=${WORKER_SECRET}"
- "THINX_HOSTNAME=${THINX_HOSTNAME}"
networks:
- internal
ports:
- 4000
labels:
- traefik.backend.worker.noexpose
volumes:
- /mnt/data/repos:/mnt/data/repos
- /mnt/data/deploy:/mnt/data/deploy
deploy:
resources:
reservations:
cpus: '0.2'
memory: 256M
limits:
cpus: '1.0'
memory: 256M
labels:
- "swarmpit.service.deployment.autoredeploy=true"
api:
depends_on:
- transformer
- thinx-redis
- mosquitto
networks:
- traefik-public
- internal
env_file: .env
image: registry.thinx.cloud:5000/thinx/api
environment:
- "ENVIRONMENT=${ENVIRONMENT}"
- "COUCHDB_USER=${COUCHDB_USER}"
- "COUCHDB_PASS=${COUCHDB_PASS}"
- "WORKER_SECRET=${WORKER_SECRET}"
- "GOOGLE_OAUTH_ID=${GOOGLE_OAUTH_ID}"
- "GOOGLE_OAUTH_SECRET=${GOOGLE_OAUTH_SECRET}"
- "GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}"
- "GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}"
- 'MAILGUN_API_KEY=${MAILGUN_API_KEY}'
- 'SLACK_WEBHOOK=${SLACK_WEBHOOK}'
ports:
- '7442:7442'
- '7443:7443'
- '4000'
volumes:
- '/mnt/data/thinx/eu/statistics:/opt/thinx/thinx-device-api/statistics'
- '/mnt/data/thinx/eu/deploy:/mnt/data/deploy'
- '/mnt/data/thinx/eu/mosquitto:/mnt/data/mosquitto'
- '/mnt/data/thinx/eu/repos:/mnt/data/repos'
- '/mnt/data/thinx/eu/ssl:/mnt/data/ssl'
- '/mnt/data/thinx/eu/ssh_keys:/mnt/data/ssh_keys'
- '/mnt/data/thinx/eu/conf:/mnt/data/conf'
- '/mnt/data/thinx/eu/statistics:/mnt/data/statistics'
- '/mnt/data/thinx/eu/test-reports:/mnt/data/test-reports'
- '/var/run/docker.sock:/var/run/docker.sock'
- '/var/lib/docker'
- '/cache'
deploy:
resources:
reservations:
cpus: '0.5'
memory: 1024M
limits:
cpus: '1.0'
memory: 2048M
labels:
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https" # 7444 websocket
- "traefik.http.services.thinx-api.loadbalancer.server.port=7442"
- "traefik.enable=true"
- "traefik.docker.network=traefik-public"
- "traefik.constraint-label=traefik-public"
- "traefik.http.routers.thinx-api-http.rule=Host(`${THINX_HOSTNAME}`)"
- "traefik.http.routers.thinx-api-http.entrypoints=http,thxp"
- "traefik.http.routers.thinx-api-http.middlewares=https-redirect"
- "traefik.http.routers.thinx-api-https.rule=Host(`${THINX_HOSTNAME}`)"
- "traefik.http.routers.thinx-api-https.entrypoints=https,thxps"
- "traefik.http.routers.thinx-api-https.tls=true"
- "traefik.http.routers.thinx-api-https.tls.certresolver=le"
- "swarmpit.service.deployment.autoredeploy=true"
console:
depends_on:
- api
env_file: .env
image: registry.thinx.cloud:5000/thinx/console
networks:
- traefik-public
# - internal # why?
ports:
- 7440:80
# logging:
# driver: none
environment:
- "LANDING_HOSTNAME=${LANDING_HOSTNAME}"
- "WEB_HOSTNAME=${WEB_HOSTNAME}"
- "API_HOSTNAME=${API_HOSTNAME}"
- "API_BASEURL=${API_BASEURL}"
- "ENTERPRISE=${ENTERPRISE}"
- "ENVIRONMENT=${ENVIRONMENT}"
- "GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID}"
- "ROLLBAR_ACCESS_TOKEN=${ROLLBAR_ACCESS_TOKEN}"
- "CRISP_WEBSITE_ID=${CRISP_WEBSITE_ID}"
deploy:
resources:
reservations:
cpus: '0.5'
memory: 32M
limits:
cpus: '1.0'
memory: 256M
labels:
# should be 7440, but the 80 port of container is exposed anyway in swarm mode
- "traefik.http.services.thinx-console.loadbalancer.server.port=80"
- "traefik.enable=true"
- "traefik.docker.network=traefik-public"
- "traefik.constraint-label=traefik-public"
- "traefik.http.routers.thinx-console-http.rule=Host(`${WEB_HOSTNAME}`)"
- "traefik.http.routers.thinx-console-http.entrypoints=http"
- "traefik.http.routers.thinx-console-http.middlewares=https-redirect"
- "traefik.http.routers.thinx-console-https.rule=Host(`${WEB_HOSTNAME}`)"
- "traefik.http.routers.thinx-console-https.entrypoints=https"
- "traefik.http.routers.thinx-console-https.tls=true"
- "traefik.http.routers.thinx-console-https.tls.certresolver=le"
- "swarmpit.service.deployment.autoredeploy=true"