From 2c78aaf72c0dbdc85056a6aab68595ea0101d9dc Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Jan 04 2024 15:32:19 +0000 Subject: Add healthchecks to docker-compose.yml This allows the pods to be started once the required containers are up, without need for hacky sleep. --- diff --git a/docker-compose.yml b/docker-compose.yml index 4121d21..c230cf9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,11 @@ services: - 15692:15692 volumes: - odcs-rabbitmq:/var/lib/rabbitmq/:z + healthcheck: + test: ["CMD-SHELL", "rabbitmq-diagnostics -q status"] + interval: 5s + timeout: 2s + retries: 5 postgres: image: postgres:9 @@ -20,6 +25,11 @@ services: POSTGRES_USER: ${POSTGRES_USER} volumes: - odcs-postgres:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] + interval: 5s + timeout: 2s + retries: 5 backend: build: @@ -37,8 +47,10 @@ services: - ".:/src:z" - odcs-composes:/mnt/odcs:z depends_on: - - rabbitmq - - postgres + rabbitmq: + condition: service_healthy + postgres: + condition: service_healthy frontend: build: @@ -49,12 +61,13 @@ services: entrypoint: ["/bin/sh","-c"] command: - | - sleep 10 python3 /src/server/odcs/server/manage.py db upgrade python3 /src/server/odcs/server/manage.py run --host 0.0.0.0 depends_on: - - rabbitmq - - postgres + rabbitmq: + condition: service_healthy + postgres: + condition: service_healthy ports: - 5000:5000 volumes: @@ -79,7 +92,8 @@ services: - | celery-3 -b rabbitmq -A odcs.server.celery_tasks beat --loglevel=debug depends_on: - - rabbitmq + rabbitmq: + condition: service_healthy volumes: - ".:/src:z" - odcs-composes:/mnt/odcs:z