From fc5fa9f740a2cfb739b8af16299b2fb0b35c0708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 17 Nov 2024 16:50:10 +0100 Subject: [PATCH] Fix startup issue with postgres on first start. Implement health check of postgres and delay django container until it's healthy. --- compose.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index d273b48..806ca0c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,7 +20,8 @@ services: networks: - backendnet depends_on: - - "shimatta-kenkyusho-db" + shimatta-kenkyusho-db: + condition: service_healthy shimatta-kenkyusho-db: image: postgres:16.5-alpine @@ -31,6 +32,11 @@ services: - "${PGDATA:-./run/pgdata}:/var/lib/postgresql/data" networks: - backendnet + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 networks: backendnet: