-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-compose.yml
444 lines (440 loc) · 10 KB
/
docker-compose.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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
version: "3.6"
networks:
default:
driver: bridge
services:
init-config:
image: busybox:stable
command:
- sh
- -e
- -c
- |
rm -rf /etc/sigopt/server-config/*
cp /sigopt-server/config/sigopt/* /etc/sigopt/server-config/
cat <<'EOF' >/etc/sigopt/server-config/00_secrets.yml
user_uploads:
s3:
aws_secret_access_key: '$MINIO_ROOT_PASSWORD'
web:
cookiejar_credentials:
secretAccessKey: '$MINIO_ROOT_PASSWORD'
EOF
echo '$MINIO_ROOT_PASSWORD' >/etc/minio/password.txt
volumes:
- ./config:/sigopt-server/config
- minio-config:/etc/minio
- server-config:/etc/sigopt/server-config
read_only: true
cap_drop:
- "ALL"
security_opt:
- "no-new-privileges:true"
test-runner:
build: &test-runner-build
dockerfile: docker/images/test-runner/Dockerfile
args:
- NODE_MAJOR
- PROTOBUF_VERSION
- PYTHON_MAJOR
- PYTHON_MINOR
environment:
- ENABLE_CONTRACTS=x
- &server-config-env SIGOPT_SERVER_CONFIG_DIR
- ALLOW_SLOW=1
- REQUESTS_CA_BUNDLE=/etc/ssl/certs/sigopt-root-ca.crt
- &api-tls-verify-env SIGOPT_API_VERIFY_SSL_CERTS=/etc/ssl/certs/sigopt-root-ca.crt
volumes:
- &rootca-volume ./artifacts/tls/root-ca.crt:/etc/ssl/certs/sigopt-root-ca.crt:ro
- &sigopt-config-volume server-config:/etc/sigopt/server-config
- ./junit-results:/sigopt-server/junit-results
- ./screenshots/failure:/sigopt-server/screenshots/failure
- ./failure_console_logs:/sigopt-server/failure_console_logs
- /dev/shm:/dev/shm
- &pg-sock-volume pg-sock:/var/run/postgresql
- &redis-run-volume redis-run:/var/run/redis
read_only: false
cap_drop:
- "ALL"
security_opt:
- "no-new-privileges:true"
tmpfs:
- /var/tmp
smtp:
build:
<<: *test-runner-build
restart: on-failure:5
entrypoint:
- /usr/bin/env
command:
- python
- -m
- integration.utils.mail
- --send-port=6001
- --receive-port=6002
networks:
default:
aliases:
- smtp.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 64M
pids: 16
read_only: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:6002/health"]
interval: "30s"
timeout: "10s"
retries: 3
start_period: "30s"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
tmpfs:
- /tmp
createdb:
build: &zigopt-build
dockerfile: docker/images/zigopt/Dockerfile
args:
- PROTOBUF_VERSION
- PYTHON_MAJOR
- PYTHON_MINOR
entrypoint:
- python
- -m
- zigopt.utils.create_database
environment:
- ENABLE_CONTRACTS
- *server-config-env
read_only: true
volumes:
- *sigopt-config-volume
- *pg-sock-volume
tmpfs:
- /tmp
cap_drop:
- "ALL"
security_opt:
- "no-new-privileges:true"
nginx:
build:
dockerfile: docker/images/nginx/Dockerfile
args:
- NGINX_VERSION
restart: on-failure:5
volumes:
- ./artifacts/tls:/etc/ssl/sigopt:ro
tmpfs:
- /var/cache/nginx
- /var/run/nginx
networks:
default:
aliases:
- sigopt.ninja
ports:
- "127.0.0.1:4443:4443" # web app (and api via /api)
- "127.0.0.1:9000:9000" # minio
deploy:
resources:
limits:
cpus: "1"
memory: 64M
pids: 2
read_only: true
healthcheck:
test: ["CMD", "test", "-f", "/var/run/nginx/nginx.pid"]
interval: "1s"
timeout: "1s"
retries: 0
security_opt:
- "no-new-privileges:true"
cap_add:
- "CHOWN"
- "DAC_OVERRIDE"
- "SETGID"
- "SETUID"
cap_drop:
- "ALL"
api:
build:
<<: *zigopt-build
restart: on-failure:5
command:
- /usr/local/bin/gunicorn_serve.sh
- -b
- 0.0.0.0:5000
- zigopt.api.main:GUNICORN_ENTRY_POINT
environment: &zigopt_environment
- ENABLE_CONTRACTS
- *server-config-env
- sigopt_server_version
volumes:
- *sigopt-config-volume
- *pg-sock-volume
- *redis-run-volume
tmpfs:
- /tmp
networks:
default:
aliases:
- api.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 512M
pids: 64
read_only: true
healthcheck:
test:
- CMD
- python
- -c
- |
import requests
requests.get("http://localhost:5000/health").raise_for_status()
interval: "30s"
timeout: "10s"
retries: 3
start_period: "15s"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
web-server:
build:
dockerfile: docker/images/web/Dockerfile
args:
- NODE_MAJOR
environment:
- *server-config-env
- "NODE_EXTRA_CA_CERTS=/sigopt-server/artifacts/tls/root-ca.crt"
- sigopt_server_version
- ALLOW_DECRYPT_COOKIE_ENDPOINT=1
volumes:
- ./artifacts/tls:/sigopt-server/artifacts/tls:ro
- *sigopt-config-volume
networks:
default:
aliases:
- app.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 4G
pids: 64
read_only: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000"]
interval: "10s"
timeout: "10s"
retries: 3
start_period: "2m"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
qworker:
build:
<<: *zigopt-build
restart: on-failure:5
command:
- python
- -m
- zigopt.queue.api
- optimization
environment: *zigopt_environment
volumes:
- *sigopt-config-volume
- *pg-sock-volume
- *redis-run-volume
tmpfs:
- /tmp
deploy:
resources:
limits:
cpus: "1"
memory: 512M
pids: 32
read_only: true
healthcheck: &qworker-healthcheck
test:
- CMD
- bash
- -e
- -opipefail
- -c
- ps awx | grep zigopt.queue.api
interval: "1s"
timeout: "1s"
retries: 1
start_period: "10s"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
qworker-analytics:
build:
<<: *zigopt-build
restart: on-failure:5
command:
- python
- -m
- zigopt.queue.api
- analytics
environment: *zigopt_environment
volumes:
- *sigopt-config-volume
- *pg-sock-volume
- *redis-run-volume
tmpfs:
- /tmp
deploy:
resources:
limits:
cpus: "1"
memory: 512M
pids: 32
read_only: true
healthcheck:
<<: *qworker-healthcheck
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
postgres:
restart: on-failure:5
image: "postgres:${POSTGRES_VERSION}"
volumes:
- *pg-sock-volume
- pg-data:/var/lib/postgresql/data
tmpfs:
- /tmp
network_mode: none
read_only: true
deploy:
resources:
limits:
cpus: "1"
memory: 1G
pids: 32
healthcheck:
test:
["CMD", "psql", "-h", "localhost", "-U", "postgres", "-c", "SELECT 1;"]
interval: "1s"
timeout: "1s"
retries: 0
start_period: "10s"
security_opt:
- "no-new-privileges:true"
cap_add:
- "CHOWN"
- "FOWNER"
- "SETGID"
- "SETUID"
cap_drop:
- "ALL"
redis:
restart: on-failure:5
image: "redis:${REDIS_VERSION}"
entrypoint:
- redis-server
command:
- /etc/redis/redis.conf
volumes:
- *redis-run-volume
- ./redis.conf:/etc/redis/redis.conf
network_mode: none
deploy:
resources:
limits:
cpus: "1"
memory: 128M
pids: 16
read_only: true
healthcheck:
test: ["CMD", "redis-cli", "PING"]
interval: "1s"
timeout: "1s"
retries: 0
start_period: "10s"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
init-minio-cookiejar:
image: "quay.io/minio/mc"
entrypoint: ["/bin/sh", "-e", "-c"]
command:
- |
mc alias set sigopt http://minio.internal.sigopt.ninja:9000 ROOTUSER '$MINIO_ROOT_PASSWORD'
mc mb --ignore-existing sigopt/sigopt-cookiejar
read_only: true
cap_drop:
- "ALL"
tmpfs:
- /root/.mc
security_opt:
- "no-new-privileges:true"
init-minio-filestorage:
image: "quay.io/minio/mc"
entrypoint: ["/bin/sh", "-e", "-c"]
command:
- |
mc alias set sigopt http://minio.internal.sigopt.ninja:9000 ROOTUSER '$MINIO_ROOT_PASSWORD'
mc mb --ignore-existing sigopt/sigopt-user-uploads
read_only: true
cap_drop:
- "ALL"
tmpfs:
- /root/.mc
security_opt:
- "no-new-privileges:true"
minio:
restart: on-failure:5
image: "quay.io/minio/minio"
entrypoint:
- sh
- -e
- -c
- |
export MINIO_ROOT_PASSWORD="$$(cat /root/.minio/password.txt)"
exec /usr/bin/docker-entrypoint.sh server /var/lib/minio/data
environment:
- MINIO_ROOT_USER=ROOTUSER
volumes:
- minio-data:/var/lib/minio/data
- minio-config:/root/.minio
networks:
default:
aliases:
- minio.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 256M
pids: 64
read_only: true
healthcheck:
test: ["CMD", "curl", "http://localhost:9000"]
interval: "5s"
timeout: "1s"
retries: 0
start_period: "10s"
security_opt:
- "no-new-privileges:true"
cap_drop:
- "ALL"
volumes:
minio-config: {}
minio-data: {}
pg-data: {}
pg-sock: {}
redis-run: {}
sigopt-python: {}
server-config: {}