feat: phase 6 production hardening + DB-to-DB transfer

Security:
- Graceful shutdown: http.Server + signal.NotifyContext, 10s drain,
  retention sweeper cancelled before pool close
- Scoped API keys (migration 00006): ingest/read/write/admin enforced in
  auth middleware; scope picker + badges in Settings UI; scopeless legacy
  keys act as admin. Read-only keys now get 403 on ingest (verified live)
- nginx: baseline security headers on all responses, CSP scoped to SPA;
  fixed add_header inheritance shadowing
- better-auth rate limit enabled unconditionally (was gated on NODE_ENV,
  which the shipped .env sets to development)
- Mailpit moved to docker-compose.dev.yml; prod compose cannot expose it
- setup.sh generates PRIMORA_ENCRYPTION_KEY

Reliability/ops:
- Retention: per-project retention_{events,audit,webhook}_days
  (migration 00007, 0=off) + hourly RetentionSweeper; edit UI in Projects
- GET /api/v1/metrics Prometheus exposition
- compose: healthchecks + restart policies everywhere, dragonfly pinned
  to v2.0.0, depends_on service_healthy
- backup.sh/restore.sh (pg_dump -Fc + storage volume); restore verified
  against scratch postgres+volume
- .dockerignore: exclude target dirs (build context was 4.7GB)

Correctness/testing:
- DBX transfer endpoint: POST /db-connections/:id/transfer — SQL or Redis
  target, 1000-row bound, server-side creds (verified live pg→dragonfly)
- Pagination audit: ListComponents capped at 500 (auto-registers)
- CI: goose up/reset/up job + compose e2e-smoke job (smoke-e2e.sh
  verified locally: signup, bootstrap, scoped keys, ingest, metrics)
- k6 load sanity script: 6650 reqs, ~217/s, 0 real failures, p95 221ms
  (429s = configured rate limiter working)

Docs: DEPLOYMENT_GUIDE.md, PRODUCTION_READINESS.md; verify script
repaired (stale refs + set -e arithmetic abort). ROADMAP: phase 2 +
phase 6 marked complete.

Authored By: TDvorak <[email protected]>

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-09-17 09:15:42 +02:00
1 parent 1b34dd43bb
commit 55edbf8b56
64 files changed
+2058 -165

No files matched your search

+35 -15
View File
@@ -14,18 +14,18 @@ services:
interval: 5s
timeout: 5s
retries: 20
restart: unless-stopped
dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly:latest
image: docker.dragonflydb.io/dragonflydb/dragonfly:v2.0.0
command: ["--logtostderr", "--proactor_threads=4"]
ports:
- "${DRAGONFLY_PORT:-6379}:6379"
restart: unless-stopped
mailpit:
image: axllent/mailpit:latest
ports:
- "${MAILPIT_HTTP_PORT}:8025"
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 6379 ping | grep -q PONG"]
interval: 10s
timeout: 3s
retries: 10
restart: unless-stopped
backend:
@@ -47,6 +47,12 @@ services:
condition: service_started
volumes:
- backend_storage:/data/storage
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://localhost:8080/api/v1/health/liveness || exit 1"]
interval: 15s
timeout: 5s
retries: 10
start_period: 20s
restart: unless-stopped
auth:
@@ -61,15 +67,17 @@ services:
BETTER_AUTH_URL: http://localhost/auth
AUTH_BASE_URL: http://localhost/auth
VITE_APP_URL: http://localhost
SMTP_HOST: mailpit
SMTP_PORT: 1025
depends_on:
postgres:
condition: service_healthy
dragonfly:
condition: service_started
mailpit:
condition: service_started
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3001/health >/dev/null 2>&1 || exit 1"]
interval: 15s
timeout: 5s
retries: 10
start_period: 20s
restart: unless-stopped
frontend:
@@ -88,19 +96,31 @@ services:
condition: service_started
auth:
condition: service_started
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost/ >/dev/null 2>&1 || exit 1"]
interval: 15s
timeout: 5s
retries: 10
restart: unless-stopped
nginx:
image: nginx:1.27-alpine
depends_on:
- backend
- auth
- frontend
- mailpit
backend:
condition: service_started
auth:
condition: service_started
frontend:
condition: service_started
ports:
- "${NGINX_PORT}:80"
volumes:
- ./infra/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost/nginx-health >/dev/null 2>&1 || exit 1"]
interval: 15s
timeout: 5s
retries: 10
restart: unless-stopped
volumes: