Skip to content

Commit

Permalink
Prevent some services from starting until mongo-init finishes running
Browse files Browse the repository at this point in the history
  • Loading branch information
eecavanna committed Mar 5, 2025
1 parent 7085288 commit c5801a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 9 additions & 3 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ services:
DAGSTER_POSTGRES_PASSWORD: "postgres_password"
DAGSTER_POSTGRES_DB: "postgres_db"
depends_on:
- dagster-postgresql
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

Expand All @@ -75,6 +78,10 @@ services:
- "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 }

# Short-lived MongoDB server used to initialize the one used by the FastAPI application.
mongo-init:
Expand All @@ -84,8 +91,7 @@ services:
- ./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
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.
Expand Down
1 change: 1 addition & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:
container_name: test
env_file: .env.test
depends_on:
mongo-init: { condition: service_completed_successfully }
mongo: { condition: service_started }
fastapi: { condition: service_started }
dagster-daemon: { condition: service_started }
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ services:
extends: { file: docker-compose.base.yml, service: fastapi }
command: ["uvicorn", "nmdc_runtime.api.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]
env_file: .env
# 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 }

# Short-lived MongoDB server used to initialize the one used by the FastAPI application.
mongo-init:
Expand Down

0 comments on commit c5801a0

Please sign in to comment.