Two HIGH deployment fixes found in the go-live review, plus two cheap backstops. HIGH 1 — Postgres was published to the public internet. The committed, auto-merged docker-compose.override.yml mapped 5432:5432 on 0.0.0.0 (and a Docker publish bypasses ufw), so a `docker compose up` on the prod host exposed the DB with the .env password. Bind the dev port to 127.0.0.1 so it's reachable only from the host's loopback even when the override lands in prod. .env.example also stops shipping `secret` as the DB password (now CHANGE_ME_*). HIGH 2 — the JWT-secret production guard was inert. APP_ENV was never set to production (defaulted to development), so the guard never ran; and it only matched one stale dev sentinel, not the `.env.example` placeholder that an operator is most likely to leave in place. Now: docker-compose.yml forces APP_ENV=production on the app service, and config.rs refuses to boot in production on any placeholder (change/example/placeholder/replace) or any secret < 64 chars. Verified: placeholder and short secrets are rejected; a 128-char secret passes. This turns "looks protected" into actually protected. Backstops: - frontend container now runs as the non-root `node` user (the backend was already hardened; the frontend wasn't). - app gets mem_limit 3g so a miss in the in-app upload RAM caps OOM-kills the container instead of the 8 GB host. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
1.5 KiB
YAML
67 lines
1.5 KiB
YAML
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
app:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
# Force production mode here (not via .env, which is easy to forget) so the
|
|
# backend's JWT-secret guard actually fires on this deployment.
|
|
environment:
|
|
APP_ENV: production
|
|
# Backstop the in-app upload RAM caps: if anything slips the per-request
|
|
# bounds, the container is OOM-killed instead of the 8 GB host.
|
|
mem_limit: 3g
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- media_data:/media
|
|
expose:
|
|
- "3000"
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
depends_on:
|
|
- app
|
|
expose:
|
|
- "3001"
|
|
|
|
caddy:
|
|
image: caddy:2-alpine
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
|
- caddy_data:/data
|
|
depends_on:
|
|
- app
|
|
- frontend
|
|
|
|
volumes:
|
|
postgres_data:
|
|
media_data:
|
|
caddy_data:
|