- postgres 1g + oom_score_adj -500; api 1536m + init; web 768m; caddy 128m (BUG-2416 hardening kept; web keeps its own SIGTERM handling) - disk alert 80% -> 65%, below the 70% backup stop line - ops-check: container_memory_high at 85% of the container's own limit - after a verified production deploy: keep newest 5 pre-release recovery points (+ baseline) and current/previous app images; dry-run supported Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
79 lines
1.9 KiB
YAML
79 lines
1.9 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
|
|
# BUG-2428: 1 GB (peak 202 MB; the rest is cache). When the host runs out of
|
|
# memory the kernel kills the database last.
|
|
mem_limit: 1g
|
|
oom_score_adj: -500
|
|
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:
|