From 98e58581e28ade0f305332494bc1ece0c91dd2f6 Mon Sep 17 00:00:00 2001 From: theshamuel Date: Fri, 5 May 2023 23:53:16 +0100 Subject: [PATCH] add health-check for db container I'd like to propose a minor changes that can bring more stability in launching the umami server with docker-compose by adding a certain healthcheck for db container and a certain condition for depends_on directive for umami-app container --- docker-compose.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index bd63c68b..9b63c580 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,8 @@ services: DATABASE_TYPE: postgresql APP_SECRET: replace-me-with-a-random-string depends_on: - - db + db: + condition: service_healthy restart: always db: image: postgres:15-alpine @@ -22,5 +23,10 @@ services: - ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro - umami-db-data:/var/lib/postgresql/data restart: always + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 5s + timeout: 5s + retries: 5 volumes: umami-db-data: