From f4b19d111c32668802d1c1be120f5e8194867fd7 Mon Sep 17 00:00:00 2001 From: Akumatic Date: Fri, 23 May 2025 23:28:35 +0200 Subject: [PATCH] Reintroduce healthcheck for database While the new image (ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0) includes a healthcheck now, it only considers POSTGRES_DB and POSTGRES_USER, not POSTGRES_DB_FILE and POSTGRES_USER_FILE used with docker secrets --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 85f58c5..4ae9985 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,6 +62,16 @@ services: image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0 container_name: immich_db_pg14 restart: unless-stopped + healthcheck: + test: [ CMD-SHELL, + "pg_isready -d `cat $$POSTGRES_DB_FILE` -U `cat $$POSTGRES_USER_FILE` || exit 1;", + "Chksum=$$(psql -d `cat $$POSTGRES_DB_FILE` -U `cat $$POSTGRES_USER_FILE` --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database');", + "echo 'checksum failure count is $$Chksum';", + "[[ $$Chksum = '0' ]] || exit 1" + ] + interval: 5m + start_interval: 30s + start_period: 5m volumes: - db:/var/lib/postgresql/data networks: