Files
Jyotisha/deploy/docker-compose.postgres.yml
T
ClaudeandClaude Opus 5.5 63c28d0f13
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m10s
Independent Staging Quality Gate / validate-python (push) Successful in 7m44s
Independent Staging Quality Gate / publish (push) Successful in 3m32s
fix(db): one connection budget for every web pool; max_connections 60 (BUG-2345, #349)
Four pools at max 10 each (40) ran against max_connections=30. Pool maxima now
come from lib/db/pool-limits.ts (identity 6, app 12, service 8, admin 3,
health 1 = 30, env-tunable 1-20) with a reserve of 10 for backup, migration,
psql and the second web container during a deploy. Idle connections close
after 10 s. Postgres max_connections 30 -> 60. A test pins the budget against
the compose file and forbids hard-coded pool maxima.

Production picks this up on the next deploy: run-production-deploy.sh runs
`compose up -d --wait postgres`, which recreates the Postgres container once
(a few seconds; data stays on the volume).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-25 10:25:23 +08:00

75 lines
1.7 KiB
YAML

services:
postgres:
image: postgres:17-alpine
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
shm_size: 128mb
env_file:
- ${DATABASE_ENV_FILE:-../.env.staging.database}
command:
- postgres
- -c
- max_connections=60
- -c
- shared_buffers=256MB
- -c
- effective_cache_size=1GB
- -c
- work_mem=4MB
volumes:
- postgres_data:/var/lib/postgresql/data
- ./postgres/001-bootstrap-roles.sh:/docker-entrypoint-initdb.d/001-bootstrap-roles.sh:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
networks: [app]
migrator:
image: ${WEB_IMAGE:-jyotisha-web:local}
profiles: ["migration"]
restart: "no"
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
env_file:
- ${DATABASE_ENV_FILE:-../.env.staging.database}
working_dir: /app/frontend
command: ["npm", "run", "db:migrate"]
depends_on:
postgres:
condition: service_healthy
networks: [app]
migration-checker:
image: ${WEB_IMAGE:-jyotisha-web:local}
profiles: ["migration-check"]
restart: "no"
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
env_file:
- ${DATABASE_ENV_FILE:-../.env.staging.database}
working_dir: /app/frontend
command: ["npm", "run", "db:migrate:check"]
depends_on:
postgres:
condition: service_healthy
networks: [app]
volumes:
postgres_data:
networks:
app: