Skip to content

Commit

Permalink
Fix: Docker Compose Example (#25546)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Docker Compose example deployment for Dagster throws errors on
initialisation because the webserver and daemon do not wait for the
postgreSQL database to be ready before attempting to connect.

Added healthcheck to postgresql container to fix this issue.

## How I Tested These Changes

Works on my machine and a new EC2 instance with relevant bits installed.
  • Loading branch information
aleexharris authored Oct 29, 2024
1 parent 6a46878 commit 2e54e69
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions examples/deploy_docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ version: "3.7"

services:
# This service runs the postgres DB used by dagster for run storage, schedule storage,
# and event log storage.
# and event log storage. Depending on the hardware you run this Compose on, you may be able
# to reduce the interval and timeout in the healthcheck to speed up your `docker-compose up` times.
docker_example_postgresql:
image: postgres:11
container_name: docker_example_postgresql
Expand All @@ -12,6 +13,11 @@ services:
POSTGRES_DB: "postgres_db"
networks:
- docker_example_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres_user -d postgres_db"]
interval: 10s
timeout: 8s
retries: 5

# This service runs the gRPC server that loads your user code, in both dagster-webserver
# and dagster-daemon. By setting DAGSTER_CURRENT_IMAGE to its own image, we tell the
Expand Down Expand Up @@ -64,8 +70,10 @@ services:
networks:
- docker_example_network
depends_on:
- docker_example_postgresql
- docker_example_user_code
docker_example_postgresql:
condition: service_healthy
docker_example_user_code:
condition: service_started

# 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.
Expand All @@ -88,8 +96,10 @@ services:
networks:
- docker_example_network
depends_on:
- docker_example_postgresql
- docker_example_user_code
docker_example_postgresql:
condition: service_healthy
docker_example_user_code:
condition: service_started

networks:
docker_example_network:
Expand Down

0 comments on commit 2e54e69

Please sign in to comment.