Files
Jyotisha/deploy/docker-compose.server.yml
T
ClaudeandClaude Opus 5.5 0054781bc5
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m34s
Independent Staging Quality Gate / validate-python (push) Successful in 8m34s
Independent Staging Quality Gate / publish (push) Successful in 3m57s
ops: container memory limits, api init, 65% disk alert, release cleanup (BUG-2428)
- 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
2026-11-26 23:18:02 +08:00

168 lines
5.3 KiB
YAML

services:
# BUG-2416 (#360): api runs as uid 10001, so the existing scratch volume (written
# as root before) is handed over first. Root here only changes file owners on that
# one volume; it has no network and exits.
api-scratch-owner:
image: ${API_IMAGE:-jyotisha-api:local}
user: "0:0"
entrypoint: ["sh", "-c", "find /app/scratch/local ! -uid 10001 -exec chown -h 10001:10001 {} + && chmod 700 /app/scratch/local"]
network_mode: none
restart: "no"
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- CHOWN
- FOWNER
- DAC_OVERRIDE
- DAC_READ_SEARCH
volumes:
- api_scratch:/app/scratch/local
api:
image: ${API_IMAGE:-jyotisha-api:local}
build:
context: ..
dockerfile: deploy/railway-api.Dockerfile
restart: unless-stopped
# BUG-2416 (#360): no root, no extra privileges, read-only image. The only
# writable places are the scratch volume (chart cache, job records) and /tmp
# (report artifacts, tempfile). The image is unchanged, so rolling back the
# application image keeps these settings.
user: "10001:10001"
read_only: true
tmpfs:
- /tmp:size=512m,mode=1777
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
pids_limit: 512
# BUG-2428: 1.5 GB (owner-approved, docs/operations/capacity-2026-11.md). Peak
# 971 MB without report generation; /tmp above is memory-backed and counts too.
# ops-check.sh alerts at 85 % of this limit.
mem_limit: 1536m
# BUG-2428: Python as PID 1 ignored SIGTERM, so every stop waited the full 10 s
# before SIGKILL. Docker's init forwards the signal and reaps children.
init: true
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
env_file:
- ${APP_ENV_FILE:-../.env.production}
environment:
PORT: 5200
GITHUB_SHA: ${GITHUB_SHA}
HOME: /tmp
PYTHONDONTWRITEBYTECODE: "1"
JYOTISH_ALLOWED_HOSTS: localhost,127.0.0.1,::1,api
expose:
- "5200"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5200/api/health', timeout=3)"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
start_interval: 1s
volumes:
# WORKDIR is /app (deploy/railway-api.Dockerfile). Chart cache, async job
# files, and high-rigor job records live under scratch/local. Named volume
# is created on first use; previous overlay data was ephemeral.
- api_scratch:/app/scratch/local
depends_on:
api-scratch-owner:
condition: service_completed_successfully
web:
image: ${WEB_IMAGE:-jyotisha-web:local}
build:
context: ..
dockerfile: deploy/railway-web.Dockerfile
args:
NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL:-}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY:-}
restart: unless-stopped
# BUG-2352 (#347): on stop, the app hands running report jobs back before exiting
# (src/lib/graceful-shutdown.ts gives them up to 35 s); Docker waits 40 s before SIGKILL.
stop_grace_period: 40s
# BUG-2416 (#360): the node image's own unprivileged user (uid 1000), read-only
# image. Writable: /tmp (live skill runtime copies, tempfiles) and Next.js's
# runtime cache dir (image optimizer); both are memory-backed and start empty.
user: "1000:1000"
read_only: true
tmpfs:
- /tmp:size=256m,mode=1777
- /app/frontend/.next/cache:size=256m,uid=1000,gid=1000,mode=0755
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
pids_limit: 512
# BUG-2428: 768 MB (peak 407 MB). No init: node handles SIGTERM itself (BUG-2352).
mem_limit: 768m
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
env_file:
- ${APP_ENV_FILE:-../.env.production}
environment:
GITHUB_SHA: ${GITHUB_SHA}
PORT: 3000
JYOTISH_API_BASE: http://api:5200
NEXT_MANUAL_SIG_HANDLE: "true"
expose:
- "3000"
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3000/api/health').then(r=>{if(!r.ok)process.exit(1)})"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
start_interval: 1s
depends_on:
api:
condition: service_healthy
caddy:
# BUG-2416 (#360): pinned by digest so a changed upstream tag never reaches production unreviewed.
image: caddy:2-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0
restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
pids_limit: 256
# BUG-2428: 128 MB (peak 30 MB).
mem_limit: 128m
logging:
driver: json-file
options:
max-size: "20m"
max-file: "10"
environment:
SITE_ADDRESS: ${SITE_ADDRESS:-https://jyotisha.chat}
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ${CADDYFILE_PATH:-./Caddyfile}:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
web:
condition: service_healthy
volumes:
caddy_data:
caddy_config:
api_scratch: