proper check for postgres health

This commit is contained in:
keyan 2024-03-07 13:18:23 -06:00
parent f2fd2eb1d7
commit b3bf3dba28
1 changed files with 10 additions and 7 deletions

View File

@ -5,10 +5,11 @@ services:
build: ./db build: ./db
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U sn -d stackernews"] test: ["CMD-SHELL", "PGPASSWORD=$$POSTGRES_PASSWORD psql -U $$POSTGRES_USER $$POSTGRES_DB -c 'SELECT 1'"]
interval: 5s interval: 10s
timeout: 5s timeout: 10s
retries: 5 retries: 10
start_period: 1m
expose: expose:
- "5432" - "5432"
ports: ports:
@ -27,7 +28,7 @@ services:
interval: 10s interval: 10s
timeout: 10s timeout: 10s
retries: 10 retries: 10
start_period: 1m30s start_period: 1m
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
@ -78,9 +79,10 @@ services:
image: darthsim/imgproxy:v3.18.1 image: darthsim/imgproxy:v3.18.1
healthcheck: healthcheck:
test: [ "CMD", "imgproxy", "health" ] test: [ "CMD", "imgproxy", "health" ]
timeout: 10s
interval: 10s interval: 10s
retries: 3 timeout: 10s
retries: 10
start_period: 1m
restart: unless-stopped restart: unless-stopped
env_file: env_file:
- ./.env.sndev - ./.env.sndev
@ -98,6 +100,7 @@ services:
interval: 10s interval: 10s
timeout: 10s timeout: 10s
retries: 10 retries: 10
start_period: 1m
restart: unless-stopped restart: unless-stopped
environment: environment:
- discovery.type=single-node - discovery.type=single-node