fix: wait for Postgres to be ready before starting Forgejo

Adds a pg_isready healthcheck to the postgres service and upgrades the
Forgejo depends_on to condition: service_healthy, preventing the
"connection refused" crash on startup.

https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH
This commit is contained in:
Claude 2026-03-26 11:27:10 +00:00
parent ea172ae336
commit 22a6ab103c
No known key found for this signature in database

View file

@ -73,6 +73,11 @@ services:
- hiy-pg-data:/var/lib/postgresql/data
# SQL files here run once on first init (ignored if data volume already exists).
- ./postgres-init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 10
networks:
- hiy-net
@ -96,7 +101,8 @@ services:
volumes:
- forgejo-data:/data
depends_on:
- postgres
postgres:
condition: service_healthy
networks:
- hiy-net