-
Notifications
You must be signed in to change notification settings - Fork 5
/
docker-compose.dev.yml
651 lines (647 loc) · 16 KB
/
docker-compose.dev.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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
version: "3.6"
networks:
default:
driver: bridge
services:
test-runner:
build:
dockerfile: docker/images/test-runner/Dockerfile
args:
- NODE_MAJOR
- PROTOBUF_VERSION
- PYTHON_MAJOR
- PYTHON_MINOR
logging: &logging
options:
max-file: "5"
max-size: "5m"
command:
- sleep
- infinity
environment:
- ENABLE_CONTRACTS=x
- SIGOPT_TEST_ROUTES_FILE=/routes/routes.json
- PYTHONPATH=/sigopt-server/src/python:/sigopt-server/test/python:/sigopt-server/test:/sigopt-server
- HOST_PWD
- REQUESTS_CA_BUNDLE=/sigopt-server/artifacts/tls/root-ca.crt
- &api-tls-verify-env SIGOPT_API_VERIFY_SSL_CERTS=/etc/ssl/certs/sigopt/root-ca.crt
volumes:
- &pg-sock-volume pg-sock:/var/run/postgresql
- &redis-run-volume redis-run:/var/run/redis
- /dev/shm:/dev/shm
- &babelrc ./.babelrc:/sigopt-server/.babelrc:ro
- &rootca-volume ./artifacts/tls:/etc/ssl/certs/sigopt:ro
- ./artifacts/tls:/sigopt-server/artifacts/tls:ro
- ./config:/sigopt-server/config:ro
- ./failure_console_logs:/sigopt-server/failure_console_logs
- ./pytest.ini:/sigopt-server/pytest.ini:ro
- ./screenshots:/sigopt-server/screenshots
- ./scratch:/sigopt-server/scratch:ro
- ./scripts:/sigopt-server/scripts:cached
- ./src/python/zigopt:/sigopt-server/src/python/zigopt:ro,cached
- ./test:/sigopt-server/test:delegated
- ./web:/sigopt-server/web:ro,cached
- ./webpack.config.script.babel.js:/sigopt-server/webpack.config.script.babel.js
- &test-routes-volume test-routes:/sigopt-server/artifacts/web/routes
working_dir: /sigopt-server
depends_on:
- postgres
- redis
deploy:
resources:
limits:
cpus: "2"
memory: 2G
pids: 256
security_opt:
- "no-new-privileges:true"
createdb:
build: &python-development-build
dockerfile: docker/images/python-development/Dockerfile
args:
- PROTOBUF_VERSION
- PYTHON_MAJOR
- PYTHON_MINOR
logging:
<<: *logging
environment:
- ENABLE_CONTRACTS=x
- SIGOPT_SERVER_CONFIG_DIR
- PYTHONPATH=/sigopt-server/src/python:/sigopt-server
stdin_open: true
tty: true
volumes:
- *pg-sock-volume
- ./config:/sigopt-server/config:ro
- ./scratch:/sigopt-server/scratch:ro
- ./src/python:/sigopt-server/src/python:ro
tmpfs:
- /tmp
working_dir: /sigopt-server
depends_on:
- postgres
deploy:
resources:
limits:
cpus: "1"
memory: 512M
read_only: true
security_opt:
- "no-new-privileges:true"
init-web:
image: busybox:stable
logging:
<<: *logging
command:
- sh
- -e
- -c
- |
rm -rf /server-bin/* /static-artifacts/*
volumes:
- server-bin:/server-bin
- static-artifacts:/static-artifacts
deploy:
resources:
limits:
cpus: "1"
memory: 8M
security_opt:
- "no-new-privileges:true"
qworker:
build:
<<: *python-development-build
restart: on-failure:5
logging:
<<: *logging
command: &qworker_command
- qworkerwatch.sh
environment:
- ENABLE_CONTRACTS=x
- &pythonpath PYTHONPATH=/sigopt-server/src/python:/sigopt-server
- &config SIGOPT_SERVER_CONFIG_DIR
- &git_hash sigopt_server_version
- MESSAGE_GROUP=optimization
stdin_open: true
tty: true
volumes: &zigopt_volumes
- *pg-sock-volume
- *redis-run-volume
- ./config:/sigopt-server/config:ro
- ./scratch:/sigopt-server/scratch:rw
- ./src/python:/sigopt-server/src/python:ro
tmpfs:
- /tmp
working_dir: /sigopt-server
depends_on: &zigopt_depends_on
- postgres
- redis
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"
qworker-analytics:
build:
<<: *python-development-build
restart: on-failure:5
logging:
<<: *logging
command: *qworker_command
environment:
- ENABLE_CONTRACTS=x
- *pythonpath
- *config
- *git_hash
- "sigopt.queue.pull_queue_name=dev-analytics-messages"
- MESSAGE_GROUP=analytics
stdin_open: true
tty: true
volumes: *zigopt_volumes
tmpfs:
- /tmp
working_dir: /sigopt-server
depends_on: *zigopt_depends_on
deploy:
resources:
limits:
cpus: "1"
memory: 512M
pids: 32
read_only: true
healthcheck:
<<: *qworker-healthcheck
security_opt:
- "no-new-privileges:true"
api:
build:
<<: *python-development-build
restart: on-failure:5
logging:
<<: *logging
command:
- bash
- -c
- "while true; do python -m zigopt.api.main --debug --threaded; sleep 1; done"
environment: &sigopt-server-env
- ENABLE_CONTRACTS=x
- PYTHONPATH=/sigopt-server/src/python:/sigopt-server
- SIGOPT_SERVER_CONFIG_DIR
- sigopt_server_version
- SIGOPT_CONTAINER_ENV=x
ports:
- target: 5000
host_ip: 127.0.0.1
stdin_open: true
tty: true
volumes:
- *pg-sock-volume
- *redis-run-volume
- "./artifacts/tls:/etc/ssl/sigopt:ro"
- "./config:/sigopt-server/config:ro"
- "./scratch:/sigopt-server/scratch:ro"
- "./src/python:/sigopt-server/src/python:ro"
tmpfs:
- /tmp
working_dir: /sigopt-server
depends_on:
- postgres
- redis
networks:
default:
aliases:
- api.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 512M
pids: 16
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"
documentation:
build:
<<: *python-development-build
logging:
<<: *logging
command:
- bash
- -c
- "python -m zigopt.api.documentation"
- docker cp documentation:/sigopt-server/scratch/swagger.json .
environment:
- ENABLE_CONTRACTS=x
- PYTHONPATH=/sigopt-server/src/python:/sigopt-server
- SIGOPT_SERVER_CONFIG_DIR
- sigopt_server_version
- SIGOPT_CONTAINER_ENV=x
- SIGOPT_SWAGGER_PATH=/sigopt-server/artifacts/
- SIGOPT_SWAGGER_FILENAME=swagger.json
stdin_open: true
tty: true
volumes:
- "./artifacts/tls:/etc/ssl/sigopt:ro"
- "./config:/sigopt-server/config:ro"
- "./artifacts:/sigopt-server/artifacts:rw"
- "./src/python:/sigopt-server/src/python:ro"
working_dir: /sigopt-server
security_opt:
- "no-new-privileges:true"
nginx:
build:
dockerfile: docker/images/nginx/Dockerfile
args:
- NGINX_VERSION
restart: on-failure:5
logging:
<<: *logging
command:
- nginx-debug
- -g
- "daemon off;"
ports:
- "127.0.0.1:4443:4443"
- "127.0.0.1:9000:9000"
volumes:
- "./artifacts/tls:/etc/ssl/sigopt"
- "./nginx:/etc/nginx:ro"
tmpfs:
- /var/cache/nginx
- /var/run/nginx
working_dir: /sigopt-server
networks:
default:
aliases:
- sigopt.ninja
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"
protowatch:
build:
<<: *python-development-build
restart: on-failure:5
logging:
<<: *logging
command:
- protowatch.sh
volumes:
- "./src/protobuf:/sigopt-server/src/protobuf:ro"
- "./src/python:/sigopt-server/src/python"
- "./tools:/sigopt-server/tools:ro"
- "./web/js:/sigopt-server/web/js"
deploy:
resources:
limits:
cpus: "1"
memory: 64M
pids: 8
read_only: true
healthcheck:
test:
- CMD
- bash
- -e
- -opipefail
- -c
- ps awx | grep run_command_on_change.py
interval: "30s"
timeout: "1s"
retries: 1
start_period: "1s"
security_opt:
- "no-new-privileges:true"
repl:
build:
<<: *python-development-build
logging:
<<: *logging
command:
- ipython
- -i
- .pyrepl.py
- --
- "--config=${SIGOPT_SERVER_CONFIG_DIR}"
environment: *sigopt-server-env
stdin_open: true
tty: true
volumes:
- *pg-sock-volume
- *redis-run-volume
- ./artifacts/tls:/etc/ssl/sigopt:ro
- .pyrepl.py:/sigopt-server/.pyrepl.py:ro
- ./config:/sigopt-server/config:ro
- ./scratch:/sigopt-server/scratch:ro
- ./src/python/zigopt:/sigopt-server/src/python/zigopt:ro
working_dir: /sigopt-server
security_opt:
- "no-new-privileges:true"
web-client:
build: &node-development-build
dockerfile: docker/images/node-development/Dockerfile
args:
- NODE_MAJOR
restart: on-failure:5
logging:
<<: *logging
command:
- bash
- -c
- |
while true; do
yarn -s webpack-dev-server \
--config=./web/js/webpack/client_side.config.babel.js \
--env=NODE_ENV=development \
--env=PUBLIC_PATH=/webpack/ \
"--env=SIGOPT_SERVER_CONFIG_DIR=${SIGOPT_SERVER_CONFIG_DIR}"
sleep 1
done
environment:
- sigopt_server_version
- &node-ca-certs-env "NODE_EXTRA_CA_CERTS=/sigopt-server/artifacts/tls/root-ca.crt"
- "NODE_OPTIONS=--max-old-space-size=4096"
user: root
stdin_open: true
tty: true
volumes: &web-volumes
- web-cache:/sigopt-server/.cache
- server-bin:/sigopt-server/artifacts/web/server
- static-artifacts:/sigopt-server/artifacts/web/static
- *babelrc
- ./artifacts/tls:/sigopt-server/artifacts/tls:ro
- ./config:/sigopt-server/config:ro
- ./scratch:/sigopt-server/scratch:ro
- ./web:/sigopt-server/web:ro,cached
tmpfs:
- /tmp
networks:
default:
aliases:
- webpack.internal.sigopt.ninja
deploy:
resources:
limits:
cpus: "1"
memory: 4G
pids: 64
read_only: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7800"]
interval: "10s"
timeout: "10s"
retries: 3
start_period: "1m"
security_opt:
- "no-new-privileges:true"
web-server:
build:
<<: *node-development-build
restart: on-failure:5
logging:
<<: *logging
command:
- bash
- -c
- |
while true; do
yarn -s webpack-dev-server \
--config=./web/js/webpack/server_side.config.babel.js \
--env=NODE_ENV=development \
--env=PUBLIC_PATH=/webpack/ \
"--env=SIGOPT_SERVER_CONFIG_DIR=${SIGOPT_SERVER_CONFIG_DIR}"
sleep 1
done
environment:
- sigopt_server_version
- *node-ca-certs-env
- "NODE_OPTIONS=--max-old-space-size=4096"
- ALLOW_DECRYPT_COOKIE_ENDPOINT=1
user: root
stdin_open: true
tty: true
volumes: *web-volumes
tmpfs:
- /tmp
ports:
- target: 4000
host_ip: 127.0.0.1
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"
depends_on:
- minio
smtp:
build:
<<: *python-development-build
restart: on-failure:5
logging:
<<: *logging
command:
- sh
- -c
- |
while true; do
python -m integration.utils.mail --verbose
done
environment:
- ENABLE_CONTRACTS=x
- PYTHONPATH=/sigopt-server/src/python:/sigopt-server/test:/sigopt-server
volumes:
- ./config:/sigopt-server/config:ro
- ./scratch:/sigopt-server/scratch:ro
- ./src/python/zigopt:/sigopt-server/src/python/zigopt:ro,cached
- ./test/integration:/sigopt-server/test/integration:ro,cached
networks:
default:
aliases:
- smtp.internal.sigopt.ninja
working_dir: /sigopt-server
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"
postgres:
restart: on-failure:5
logging:
<<: *logging
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"
redis:
restart: on-failure:5
logging:
<<: *logging
image: "redis:${REDIS_VERSION}"
entrypoint:
- redis-server
command:
- /etc/redis/redis.conf
volumes:
- redis-run:/var/run/redis
- ./redis.conf:/etc/redis/redis.conf
network_mode: none
deploy:
resources:
limits:
cpus: "1"
memory: 128M
pids: 8
read_only: true
healthcheck:
test: ["CMD", "redis-cli", "PING"]
interval: "1s"
timeout: "1s"
retries: 0
start_period: "10s"
security_opt:
- "no-new-privileges:true"
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 CHANGEME123
mc mb --ignore-existing sigopt/sigopt-cookiejar
depends_on:
- minio
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 CHANGEME123
mc mb --ignore-existing sigopt/sigopt-user-uploads
depends_on:
- minio
minio:
logging:
<<: *logging
image: "quay.io/minio/minio"
ports:
- "9000"
networks:
default:
aliases:
- minio.internal.sigopt.ninja
environment:
- MINIO_ROOT_USER=ROOTUSER
- MINIO_ROOT_PASSWORD=CHANGEME123
volumes:
- minio-data:/var/lib/minio/data
- minio-config:/root/.minio
command:
- "server"
- "/var/lib/minio/data"
- "--console-address"
- ":9009"
deploy:
resources:
limits:
cpus: "1"
memory: 128M
pids: 32
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"
volumes:
minio-config: {}
minio-data: {}
pg-data: {}
pg-sock: {}
redis-run: {}
server-bin: {}
static-artifacts: {}
test-routes: {}
web-cache: {}