1
1
services :
2
- # This service runs the postgres DB used by dagster for run storage, schedule storage,
3
- # and event log storage.
4
- # Tests use `postgres:11` image.
5
- # https://github.com/dagster-io/dagster/blob/0.11.9/python_modules/libraries/dagster-postgres/dagster_postgres_tests/docker-compose.yml
2
+
3
+ # Postgres server used by Dagster.
4
+ #
5
+ # > This service runs the postgres DB used by dagster for run storage, schedule storage,
6
+ # > and event log storage.
7
+ # > Tests use `postgres:11` image.
8
+ # > https://github.com/dagster-io/dagster/blob/0.11.9/python_modules/libraries/dagster-postgres/dagster_postgres_tests/docker-compose.yml
9
+ #
6
10
dagster-postgresql :
7
11
image : postgres:11
8
12
container_name : dagster-postgresql
9
- volumes :
10
- - nmdc_runtime_test_postgres_data:/var/lib/postgresql/data
11
13
environment :
12
14
POSTGRES_USER : " postgres_user"
13
15
POSTGRES_PASSWORD : " postgres_password"
14
16
POSTGRES_DB : " postgres_db"
17
+ volumes :
18
+ - nmdc_runtime_test_postgres_data:/var/lib/postgresql/data
15
19
16
- # This service runs dagit.
17
- # Since our instance uses the QueuedRunCoordinator, any runs submitted from dagit will be put on
18
- # a queue and later dequeued and launched by dagster-daemon.
20
+ # Web server that hosts the Dagster web UI.
21
+ #
22
+ # > This service runs dagit.
23
+ # > Since our instance uses the QueuedRunCoordinator, any runs submitted from dagit will be put on
24
+ # > a queue and later dequeued and launched by dagster-daemon.
25
+ #
19
26
dagster-dagit :
20
27
build :
21
28
context : .
@@ -27,8 +34,6 @@ services:
27
34
- " 3000"
28
35
ports :
29
36
- " 3000:3000"
30
- env_file :
31
- - .env.test
32
37
environment :
33
38
DAGSTER_POSTGRES_USER : " postgres_user"
34
39
DAGSTER_POSTGRES_PASSWORD : " postgres_password"
@@ -38,9 +43,13 @@ services:
38
43
restart : on-failure
39
44
volumes :
40
45
- ./:/opt/dagster/lib
46
+ env_file : .env.test
41
47
42
- # This service runs the dagster-daemon process, which is responsible for taking runs
43
- # off of the queue and launching them, as well as creating runs from schedules or sensors.
48
+ # Dagster daemon.
49
+ #
50
+ # > This service runs the dagster-daemon process, which is responsible for taking runs
51
+ # > off of the queue and launching them, as well as creating runs from schedules or sensors.
52
+ #
44
53
dagster-daemon :
45
54
build :
46
55
context : .
@@ -49,17 +58,20 @@ services:
49
58
container_name : dagster-daemon
50
59
entrypoint : ["tini", "--", "../lib/nmdc_runtime/site/entrypoint-daemon.sh"]
51
60
restart : on-failure
52
- env_file :
53
- - .env.test
54
61
environment :
55
62
DAGSTER_POSTGRES_USER : " postgres_user"
56
63
DAGSTER_POSTGRES_PASSWORD : " postgres_password"
57
64
DAGSTER_POSTGRES_DB : " postgres_db"
58
65
depends_on :
59
- - dagster-postgresql
66
+ dagster-postgresql : { condition: service_started }
67
+ # Wait until the MongoDB replica set has been set up by the "init container"
68
+ # before starting this Dagster daemon container.
69
+ mongo-init : { condition: service_completed_successfully }
60
70
volumes :
61
71
- ./:/opt/dagster/lib
72
+ env_file : .env.test
62
73
74
+ # Uvicorn server hosting the FastAPI application.
63
75
fastapi :
64
76
build :
65
77
context : .
@@ -68,27 +80,48 @@ services:
68
80
container_name : fastapi
69
81
ports :
70
82
- " 8000:8000"
71
- env_file :
72
- - .env.test
73
- depends_on :
74
- - mongo
75
83
volumes :
76
84
- .:/code
85
+ # Wait until the MongoDB replica set has been set up by the "init container"
86
+ # before starting this FastAPI container.
87
+ depends_on :
88
+ mongo-init : { condition: service_completed_successfully }
89
+ env_file : .env.test
90
+
91
+ # Short-lived MongoDB server used to initialize the one used by the FastAPI application.
92
+ mongo-init :
93
+ image : mongo:8.0.4
94
+ container_name : mongo-init
95
+ volumes :
96
+ - ./wait-for-it.sh:/wait-for-it.sh:ro
97
+ - .docker/mongo_init/initialize_replica_set.sh:/initialize_replica_set.sh:ro
98
+ depends_on :
99
+ mongo : { condition: service_started }
100
+ entrypoint : /bin/bash /wait-for-it.sh --host=mongo --port=27017 --timeout=20 -- /bin/sh /initialize_replica_set.sh mongo 27017 admin root
77
101
102
+ # MongoDB server used by the FastAPI application.
78
103
mongo :
79
104
image : mongo:8.0.4
80
105
container_name : mongo
81
106
ports :
82
107
- " 27018:27017"
83
- volumes :
84
- - nmdc_runtime_test_mongo_data:/data/db
85
- - ~/nmdcdb-mongodump:/nmdc_dump:ro
86
- - ./tests/mongorestore-nmdc-testdb.sh:/mongorestore-nmdc-testdb.sh:ro
87
108
restart : unless-stopped
88
109
environment :
89
110
MONGO_INITDB_ROOT_USERNAME : admin
90
111
MONGO_INITDB_ROOT_PASSWORD : root
112
+ # Configure MongoDB to run in replica set mode, so we can use MongoDB transactions.
113
+ #
114
+ # Note: Including a KeyFile is necessary when doing the combination of (a) running MongoDB in
115
+ # replica set mode and (b) running MongoDB with authentication enabled.
116
+ #
117
+ command : ["--replSet", "rs0", "--bind_ip_all", "--keyFile", "/keyFile"]
118
+ volumes :
119
+ - nmdc_runtime_test_mongo_data:/data/db
120
+ - ./mongoKeyFile:/keyFile:ro
121
+ - ~/nmdcdb-mongodump:/nmdc_dump:ro
122
+ - ./tests/mongorestore-nmdc-testdb.sh:/mongorestore-nmdc-testdb.sh:ro
91
123
124
+ # Test runner.
92
125
test :
93
126
# Prevent Docker Compose from starting this service automatically.
94
127
# Reference: https://stackoverflow.com/a/65957695
@@ -99,13 +132,13 @@ services:
99
132
dockerfile : nmdc_runtime/Dockerfile
100
133
target : test
101
134
container_name : test
102
- env_file :
103
- - .env.test
135
+ env_file : .env.test
104
136
depends_on :
105
- - mongo
106
- - fastapi
107
- - dagster-daemon
108
- - dagster-dagit
137
+ mongo-init : { condition: service_completed_successfully }
138
+ mongo : { condition: service_started }
139
+ fastapi : { condition: service_started }
140
+ dagster-daemon : { condition: service_started }
141
+ dagster-dagit : { condition: service_started }
109
142
volumes :
110
143
- .:/code
111
144
0 commit comments