-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker-compose.yml
133 lines (125 loc) · 4.4 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
services:
# Postgres server used by Dagster.
#
# > This service runs the postgres DB used by dagster for run storage, schedule storage,
# > and event log storage.
# > Tests use `postgres:11` image.
# > https://github.com/dagster-io/dagster/blob/0.11.9/python_modules/libraries/dagster-postgres/dagster_postgres_tests/docker-compose.yml
#
dagster-postgresql:
image: postgres:11
container_name: dagster-postgresql
environment:
POSTGRES_USER: "postgres_user"
POSTGRES_PASSWORD: "postgres_password"
POSTGRES_DB: "postgres_db"
volumes:
- nmdc_runtime_postgres_data:/var/lib/postgresql/data
# Web server that hosts the Dagster web UI.
#
# > This service runs dagit.
# > Since our instance uses the QueuedRunCoordinator, any runs submitted from dagit will be put on
# > a queue and later dequeued and launched by dagster-daemon.
#
dagster-dagit:
build:
context: .
dockerfile: nmdc_runtime/Dockerfile
target: dagster
container_name: dagster-dagit
entrypoint: ["tini", "--", "../lib/nmdc_runtime/site/entrypoint-dagit.sh"]
expose:
- "3000"
ports:
- "3000:3000"
environment:
DAGSTER_POSTGRES_USER: "postgres_user"
DAGSTER_POSTGRES_PASSWORD: "postgres_password"
DAGSTER_POSTGRES_DB: "postgres_db"
depends_on:
- dagster-postgresql
restart: on-failure
volumes:
- ./:/opt/dagster/lib
env_file: .env
# Dagster daemon.
#
# > This service runs the dagster-daemon process, which is responsible for taking runs
# > off of the queue and launching them, as well as creating runs from schedules or sensors.
#
dagster-daemon:
build:
context: .
dockerfile: nmdc_runtime/Dockerfile
target: dagster
container_name: dagster-daemon
entrypoint: ["tini", "--", "../lib/nmdc_runtime/site/entrypoint-daemon.sh"]
restart: on-failure
environment:
DAGSTER_POSTGRES_USER: "postgres_user"
DAGSTER_POSTGRES_PASSWORD: "postgres_password"
DAGSTER_POSTGRES_DB: "postgres_db"
depends_on:
dagster-postgresql: { condition: service_started }
# Wait until the MongoDB replica set has been set up by the "init container"
# before starting this Dagster daemon container.
mongo-init: { condition: service_completed_successfully }
volumes:
- ./:/opt/dagster/lib
env_file: .env
# Uvicorn server hosting the FastAPI application.
fastapi:
build:
context: .
dockerfile: nmdc_runtime/Dockerfile
target: fastapi
container_name: fastapi
ports:
- "8000:8000"
volumes:
- .:/code
# Wait until the MongoDB replica set has been set up by the "init container"
# before starting this FastAPI container.
depends_on:
mongo-init: { condition: service_completed_successfully }
command: ["uvicorn", "nmdc_runtime.api.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]
env_file: .env
# Short-lived MongoDB server used to initialize the one used by the FastAPI application.
mongo-init:
image: mongo:8.0.4
container_name: mongo-init
volumes:
- ./wait-for-it.sh:/wait-for-it.sh:ro
- .docker/mongo_init/initialize_replica_set.sh:/initialize_replica_set.sh:ro
depends_on:
mongo: { condition: service_started }
entrypoint: /bin/bash /wait-for-it.sh --host=mongo --port=27017 --timeout=20 -- /bin/sh /initialize_replica_set.sh mongo 27017 admin root
# MongoDB server used by the FastAPI application.
# TODO: Why does this service, which is in the dev—not test—stack, mount a volume named `tests` — is that intentional?
mongo:
image: mongo:8.0.4
container_name: mongo
ports:
- "27018:27017"
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: root
# Configure MongoDB to run in replica set mode, so we can use MongoDB transactions.
#
# Note: Including a KeyFile is necessary when doing the combination of (a) running MongoDB in
# replica set mode and (b) running MongoDB with authentication enabled.
#
command: ["--replSet", "rs0", "--bind_ip_all", "--keyFile", "/keyFile"]
volumes:
- nmdc_runtime_mongo_data:/data/db
- ./mongoKeyFile:/keyFile:ro
- ./tests:/app_tests
volumes:
nmdc_runtime_postgres_data:
driver: local
nmdc_runtime_mongo_data:
driver: local
secrets:
mongoKeyFile:
file: ./mongoKeyFile