Files
superlist/docker-compose.yml
Jose Selesan dd9cf4ce43 feat(api): ship logs and HTTP metrics to OpenObserve
Replace Pino with LogTape and add OpenTelemetry metrics, both pushed to
OpenObserve over OTLP/HTTP when OPENOBSERVE_URL is set (console only otherwise).

- lib/logger.ts: console sink (pretty in dev, JSON lines in production) plus an
  OpenObserve sink via @logtape/otel. Each request runs inside
  withContext({ requestId }), so every record logged during it carries the id.
- The request middleware logs method, path, route pattern, status, durationMs,
  userId and user agent, at error/warning/info by status (/api/health at debug).
- lib/metrics.ts: http.server.request.duration (histogram, 5 ms to 10 s) and
  http.server.active_requests, attributed by method, route pattern and status,
  exported every METRICS_EXPORT_INTERVAL_MS (15 s).
- lib/openobserve.ts holds the shared endpoint and Basic auth settings; logs and
  metrics are flushed on SIGINT/SIGTERM.
- docs/openobserve-dashboard.md explains the dashboard and its queries, and
  docs/openobserve-dashboard.json can be imported as is.
- New variables are declared in turbo.json, the .env examples and the compose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 11:59:17 -03:00

91 lines
3.2 KiB
YAML

# Dokploy deployment: the API and the static frontend behind nginx.
# The database is external (Dokploy's) and lives on the shared
# `dokploy-network`, so both services join it: `web` so Dokploy's Traefik can
# reach it via the Domains UI, `api` so it can reach the database. nginx talks
# to the API over the stack-private `internal` network, under the unique alias
# `superlist-api` (declared only there), so no other project on
# `dokploy-network` answering to `api` can ever receive our traffic.
services:
api:
build:
context: .
dockerfile: apps/api/Dockerfile
restart: unless-stopped
environment:
# Required: no sensible default for any of these.
DATABASE_URL: ${DATABASE_URL:?Set DATABASE_URL in the Dokploy env}
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?Set BETTER_AUTH_SECRET in the Dokploy env}
BETTER_AUTH_URL: ${BETTER_AUTH_URL:?Set BETTER_AUTH_URL in the Dokploy env}
CORS_ORIGIN: ${CORS_ORIGIN:?Set CORS_ORIGIN in the Dokploy env}
WEB_APP_URL: ${WEB_APP_URL:?Set WEB_APP_URL in the Dokploy env}
# Optional: sensible defaults when unset.
NODE_ENV: ${NODE_ENV:-production}
PORT: ${PORT:-4100}
LOG_LEVEL: ${LOG_LEVEL:-}
# Logs to OpenObserve (optional): without OPENOBSERVE_URL they only go to stdout.
OPENOBSERVE_URL: ${OPENOBSERVE_URL:-}
OPENOBSERVE_ORG: ${OPENOBSERVE_ORG:-default}
OPENOBSERVE_STREAM: ${OPENOBSERVE_STREAM:-superlist}
OPENOBSERVE_USER: ${OPENOBSERVE_USER:-}
OPENOBSERVE_PASSWORD: ${OPENOBSERVE_PASSWORD:-}
METRICS_EXPORT_INTERVAL_MS: ${METRICS_EXPORT_INTERVAL_MS:-15000}
RESEND_API_KEY: ${RESEND_API_KEY:-}
MAIL_FROM: ${MAIL_FROM:-}
# Dictation (optional): Groq when its key is set, else Gemini; without any key,
# dictated text is split without AI.
GROQ_API_KEY: ${GROQ_API_KEY:-}
GROQ_MODEL: ${GROQ_MODEL:-openai/gpt-oss-120b}
GROQ_TIMEOUT_MS: ${GROQ_TIMEOUT_MS:-8000}
GEMINI_API_KEY: ${GEMINI_API_KEY:-}
GEMINI_MODEL: ${GEMINI_MODEL:-gemma-4-26b-a4b-it}
GEMINI_TIMEOUT_MS: ${GEMINI_TIMEOUT_MS:-8000}
expose:
- "4100"
networks:
internal:
aliases:
- superlist-api
# Only to reach Dokploy's database; nginx never resolves the API here.
dokploy-network:
healthcheck:
test:
[
"CMD",
"bun",
"-e",
"fetch(`http://localhost:${PORT:-4100}/api/health`).then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
# Empty = same origin (nginx proxies /api/*). Only set this if the
# frontend must call the API on a different origin.
VITE_API_URL: ${VITE_API_URL:-}
restart: unless-stopped
depends_on:
api:
condition: service_healthy
expose:
- "80"
networks:
- internal
- dokploy-network
healthcheck:
test: ["CMD", "wget", "-qO", "/dev/null", "http://127.0.0.1/"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
internal:
dokploy-network:
external: true