Files
yolkbook/docker-compose.yml
derekc 37f19a83ed Implement security hardening across frontend, backend, and infrastructure
- nginx: add X-Content-Type-Options, X-Frame-Options, X-XSS-Protection,
  and Referrer-Policy headers on all responses; rate limit /api/auth/login
  to 5 req/min per IP (burst 3) to prevent brute force
- frontend: add escHtml() utility to api.js; use it on all notes fields
  across dashboard, log, history, flock, and budget pages to prevent XSS
- log.js: fix broken loadRecent() call referencing removed #recent-body
  element; replaced with loadHistory() from history.js
- schemas.py: raise minimum password length from 6 to 10 characters
- admin.py: add audit logging for password reset, disable, delete, and
  impersonate actions; fix impersonate to use named admin param for logging
- main.py: add startup env validation — exits with clear error if any
  required env var is missing; configure structured logging to stdout
- docker-compose.yml: add log rotation (10 MB / 3 files) to all services

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 23:55:08 -07:00

78 lines
2.9 KiB
YAML

services:
# ── MySQL ────────────────────────────────────────────────────────────────────
db:
image: mysql:8.0
restart: unless-stopped
env_file: .env
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql # persistent data
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro # run once on first start
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- backend
# ── FastAPI ──────────────────────────────────────────────────────────────────
api:
build: ./backend
restart: unless-stopped
env_file: .env
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
environment:
DATABASE_URL: mysql+pymysql://${MYSQL_USER}:${MYSQL_PASSWORD}@db/${MYSQL_DATABASE}
ADMIN_USERNAME: ${ADMIN_USERNAME}
ADMIN_PASSWORD: ${ADMIN_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
depends_on:
db:
condition: service_healthy # wait for MySQL to be ready before starting
networks:
- backend
# ── Nginx ────────────────────────────────────────────────────────────────────
nginx:
image: nginx:alpine
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
ports:
- "8056:80"
volumes:
- ./nginx/html:/usr/share/nginx/html:ro # static files — edit locally, live immediately
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro # nginx config
depends_on:
- api
networks:
- backend
# ── Volumes ───────────────────────────────────────────────────────────────────
volumes:
mysql_data: # survives container restarts and rebuilds
# ── Networks ──────────────────────────────────────────────────────────────────
networks:
backend:
driver: bridge