Hardened Compose, Split Modes & Reverse Proxy
Production container sandboxing, APP_MODE split topologies, and SSE-safe Nginx/Caddy templates.
Hardened Stack (deploy/docker-compose.yml)
For internet-facing deployments, deploy/docker-compose.yml enforces strict container isolation:
- Non-root
USER bryfo,read_only: trueroot filesystem (tmpfs /tmp:size=128m),cap_drop: [ALL], andno-new-privileges:true. - Memory caps (
app: 1g,postgres: 1536m+shm_size: 256m,valkey: 512mwith--maxmemory 384mb --maxmemory-policy noeviction) and10m × 3JSON log rotation.
Never Change Valkey noeviction
Changing Valkey's --maxmemory-policy noeviction to LRU/LFU will evict live Asynq tasks, rate-limit counters, Undo-Send tokens, and encrypted AI PII session maps.
Process Topologies (APP_MODE)
APP_MODE=all(default): Runs HTTP API,/api/v1/eventsSSE hub,/mcp, IMAPIDLEmanager, and Asynq worker in one process.APP_MODE=api: Stateless HTTP/SSE/MCP frontend tier behind an L7 load balancer.APP_MODE=worker: Dedicated Asynq consumer (critical:6,default:3,low:1), 6-hour GC cron, and internal/healthz+/metricslistener (WORKER_METRICS_ADDR).
Reverse Proxy & SSE Configuration
Bryfo binds to loopback (127.0.0.1:8080). Terminate TLS in Caddy or Nginx and disable response buffering on /api/v1/events and /api/v1/ai/conversations/*/messages:
location ~ ^/api/v1/(events|ai/conversations/[^/]+/messages)$ {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
}