From 2eeb9b0bd017392de3edc86f4db19bfb66a8d2f9 Mon Sep 17 00:00:00 2001 From: Aaro Koivukangas Date: Fri, 7 Aug 2026 13:05:36 +0300 Subject: [PATCH] [DockerCompose] Add host to db healthchecks to wait for initdb scripts to run --- anonyymioodi/docker-compose.yml | 8 +++++--- docker-compose.ci.yml | 20 +++++++++++--------- docker-compose.test.yml | 10 ++++++---- docker-compose.yml | 20 +++++++++++--------- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/anonyymioodi/docker-compose.yml b/anonyymioodi/docker-compose.yml index c52c0f1ad..58ca0f212 100644 --- a/anonyymioodi/docker-compose.yml +++ b/anonyymioodi/docker-compose.yml @@ -2,9 +2,11 @@ x-defaults: &defaults restart: unless-stopped x-healthcheck-defaults: &healthcheck-defaults - interval: 1s - timeout: 3s - retries: 30 + interval: 30s # Normal healthcehck interval + timeout: 5s + retries: 10 # Retries until SIGKILl + start_interval: 3s # How often healthcheck runs while starting + start_period: 15s # How long startup period is services: kone-db: diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 2eaf6a55f..b608e623b 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -4,9 +4,11 @@ x-defaults: &defaults restart: unless-stopped x-healthcheck-defaults: &healthcheck-defaults - interval: 1s - timeout: 3s - retries: 30 + interval: 30s # Normal healthcehck interval + timeout: 5s + retries: 10 # Retries until SIGKILl + start_interval: 3s # How often healthcheck runs while starting + start_period: 30s # How long startup period is services: backend: @@ -71,7 +73,7 @@ services: ports: - 4321:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults user-db: @@ -85,7 +87,7 @@ services: ports: - 4320:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults redis: @@ -112,7 +114,7 @@ services: ports: - 12345:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults sis-importer-db: @@ -124,7 +126,7 @@ services: ports: - 12346:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults jami: @@ -145,14 +147,14 @@ services: jami-db: <<: *defaults container_name: oodikone-jami-db - image: postgres:15.10 + image: registry-toska.ext.ocp-prod-0.k8s.it.helsinki.fi/jami-db environment: - PGDATA=/data - POSTGRES_PASSWORD=postgres ports: - 5433:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults # This is still needed to make backend calls correctly route from localhost:5000/api to localhost:8080 diff --git a/docker-compose.test.yml b/docker-compose.test.yml index e62dd32e5..4ea15e7df 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -4,9 +4,11 @@ x-defaults: &defaults restart: unless-stopped x-healthcheck-defaults: &healthcheck-defaults - interval: 1s - timeout: 3s - retries: 30 + interval: 30s # Normal healthcehck interval + timeout: 5s + retries: 10 # Retries until SIGKILl + start_interval: 3s # How often healthcheck runs while starting + start_period: 30s # How long startup period is services: sis-db: @@ -23,5 +25,5 @@ services: ports: - 12345:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults diff --git a/docker-compose.yml b/docker-compose.yml index f0bfea09d..1b2cab88b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,11 @@ x-build_defaults: &build_defaults dockerfile: dev.Dockerfile x-healthcheck-defaults: &healthcheck-defaults - interval: 1s - timeout: 3s - retries: 30 + interval: 30s # Normal healthcehck interval + timeout: 5s + retries: 10 # Retries until SIGKILl + start_interval: 3s # How often healthcheck runs while starting + start_period: 30s # How long startup period is services: adminer: @@ -94,7 +96,7 @@ services: volumes: - kone-db-data:/data healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults user-db: @@ -108,7 +110,7 @@ services: volumes: - user-db-data:/data healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults redis: @@ -134,7 +136,7 @@ services: ports: - 12345:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults sis-importer-db: @@ -148,7 +150,7 @@ services: ports: - 12346:5432 healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults jami: @@ -171,7 +173,7 @@ services: jami-db: <<: *defaults container_name: oodikone-jami-db - image: postgres:15.10 + image: registry-toska.ext.ocp-prod-0.k8s.it.helsinki.fi/jami-db environment: - PGDATA=/data - POSTGRES_PASSWORD=postgres @@ -180,7 +182,7 @@ services: volumes: - jami-data:/data healthcheck: - test: ['CMD', 'pg_isready', '-U', 'postgres'] + test: ['CMD', 'pg_isready', '-U', 'postgres', '-h', '127.0.0.1'] <<: *healthcheck-defaults sis-updater-worker: