compose.dokploy.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. # briven — Dokploy-managed compose (generated from compose.yml).
  2. # Dokploy controls the project name + container names, so this file omits
  3. # the top-level `name:` and per-service `container_name:` that compose.yml
  4. # pins for the raw self-host path. Keep this in sync with compose.yml.
  5. # Source of truth for the engine/services is compose.yml (DoltGres data plane).
  6. # briven — canonical self-host compose (build-from-source).
  7. #
  8. # Product line (flndrn 2026-07-21): Briven is Doltgres end-to-end.
  9. #
  10. # - control plane = DoltGres database `briven_control` on the doltgres service
  11. # (sign-in, orgs, projects, billing, Briven Auth). BRIVEN_DATABASE_URL.
  12. # - data plane = same DoltGres cluster, one DATABASE per customer project
  13. # (`proj_…`). BRIVEN_DATA_PLANE_URL. Realtime polls DOLT_HASHOF('HEAD').
  14. #
  15. # Stock Postgres (pgvector) may still exist on the host for rollback only —
  16. # live traffic must not use it. Do not reintroduce control-on-Postgres.
  17. #
  18. # This file supersedes the two earlier conflicting composes:
  19. # - the old Dolt-MySQL build (dolthub/dolt-sql-server + BRIVEN_URL mysql) —
  20. # wrong engine, broke the api. REMOVED.
  21. # - the all-pgvector build (data plane as a 2nd Postgres DB) — wrong data
  22. # plane. REPLACED by the real DoltGres service below.
  23. #
  24. # Dokploy clones the repo and runs `docker compose build` against the local
  25. # Dockerfiles — no external registry, no GHCR, no docker.sock. Per
  26. # docs/DOCKER.md §7 / infra/CLAUDE.md: every long-running service caps its
  27. # log volume via the *briven-logging anchor; no watchtower, no docker_sd,
  28. # no registry polling on the host.
  29. #
  30. # Single-machine layout, ~25 concurrent customer projects. Past that, split
  31. # the control plane onto one host and the data plane (doltgres + minio) onto
  32. # another.
  33. #
  34. # Required env (drop a `.env` next to this file — see .env.example):
  35. #
  36. # BRIVEN_DOMAIN e.g. briven.example.com
  37. # BRIVEN_BETTER_AUTH_SECRET openssl rand -hex 32
  38. # BRIVEN_AUDIT_IP_PEPPER openssl rand -hex 32
  39. # BRIVEN_ENCRYPTION_KEY openssl rand -hex 32
  40. # BRIVEN_RUNTIME_SHARED_SECRET openssl rand -hex 32
  41. # BRIVEN_POSTGRES_PASSWORD control-plane Postgres superuser password
  42. # BRIVEN_DOLTGRES_PASSWORD data-plane DoltGres superuser password
  43. # BRIVEN_MINIO_ROOT_PASSWORD MinIO root / S3 secret key
  44. # (optional) BRIVEN_MITTERA_*, BRIVEN_*_CLIENT_ID/SECRET, BRIVEN_POLAR_*,
  45. # BRIVEN_OLLAMA_*, BRIVEN_MINIO_BUCKET/REGION, BRIVEN_OPEN_SIGNUPS
  46. #
  47. # After first boot:
  48. # 1. Create the first user via the magic-link flow on https://${BRIVEN_DOMAIN}
  49. # 2. Promote to admin in the control plane:
  50. # docker exec -it briven-postgres psql -U postgres -d briven_control \
  51. # -c "UPDATE users SET is_admin = true WHERE id = '...';"
  52. # 3. Create your first project via the dashboard (provisions a DoltGres DB).
  53. x-logging: &briven-logging
  54. driver: json-file
  55. options:
  56. max-size: '10m'
  57. max-file: '3'
  58. services:
  59. # ─── control plane ────────────────────────────────────────────────────
  60. postgres:
  61. image: pgvector/pgvector:pg17
  62. restart: unless-stopped
  63. logging: *briven-logging
  64. environment:
  65. POSTGRES_PASSWORD: ${BRIVEN_POSTGRES_PASSWORD}
  66. POSTGRES_DB: briven_control
  67. volumes:
  68. - postgres_data:/var/lib/postgresql/data
  69. # Control-plane init only: enables pgvector + pg_trgm on briven_control.
  70. # No data-plane DB is created here — the data plane is the doltgres
  71. # service, with a database per project (see ADR-0002).
  72. - ./postgres-init:/docker-entrypoint-initdb.d:ro
  73. healthcheck:
  74. test: ['CMD-SHELL', 'pg_isready -U postgres -d briven_control']
  75. interval: 10s
  76. timeout: 5s
  77. retries: 5
  78. start_period: 20s
  79. networks:
  80. - briven
  81. labels:
  82. - 'briven_logs=true'
  83. # ─── data plane ───────────────────────────────────────────────────────
  84. # DoltGres = Postgres-wire, git-for-data. Each customer project is its own
  85. # DATABASE here, created by the api over the `pg` driver. The default
  86. # superuser/database is `postgres`/`postgres` (DOLTGRES_* envs override the
  87. # password).
  88. #
  89. # IMAGE IS PINNED BY DIGEST, ON PURPOSE (2026-07-07 maintenance window):
  90. # `:latest` let a deploy silently swap the database engine under live data
  91. # (prime suspect in the 2026-07-07 auth.db outage). To upgrade the engine,
  92. # change the digest here deliberately, in its own reviewed deploy.
  93. #
  94. # DATA DIR IS /var/lib/doltgres — NO "ql". The mount below once pointed at
  95. # /var/lib/doltgresql (typo), so all real data lived in an anonymous volume
  96. # that a container recreation would orphan. Fixed 2026-07-07 (data migrated
  97. # into the named volume during the maintenance window). Never change this
  98. # path without checking `config.yaml` inside the volume.
  99. doltgres:
  100. image: dolthub/doltgresql:0.57.2
  101. restart: unless-stopped
  102. logging: *briven-logging
  103. environment:
  104. DOLTGRES_USER: postgres
  105. DOLTGRES_PASSWORD: ${BRIVEN_DOLTGRES_PASSWORD}
  106. volumes:
  107. - doltgres_data:/var/lib/doltgres
  108. # Dolt-native backups land here (written by the server itself); the host
  109. # systemd job infra/backups/briven-backup.sh triggers them (gentle, one
  110. # DB at a time). The old in-compose dolt-backup sidecar was REMOVED
  111. # 2026-08-01 — its un-throttled per-DB loop helped lock DoltGres under load.
  112. - doltgres_backups:/backups
  113. healthcheck:
  114. # pg_isready ships in the doltgresql image and needs no password.
  115. test: ['CMD-SHELL', 'pg_isready -h 127.0.0.1 -p 5432 -U postgres']
  116. interval: 10s
  117. timeout: 5s
  118. retries: 5
  119. start_period: 30s
  120. networks:
  121. - briven
  122. labels:
  123. - 'briven_logs=true'
  124. # ─── data-plane backup: moved to the host systemd job (2026-08-01) ──────
  125. # The in-compose `dolt-backup` sidecar was REMOVED. Its un-throttled loop of
  126. # `dolt_backup('sync-url', …)` over every DB helped lock DoltGres 0.56.6 under
  127. # load (full-platform outage, see docs/knowledge-base.md → INCIDENT 2026-08-01).
  128. # Backups now run from infra/backups/briven-backup.sh (systemd timer): a GENTLE,
  129. # one-DB-at-a-time, throttled `dolt_backup` pass on the fixed 0.57.2 engine,
  130. # plus off-site mirror. Restorable via `dolt backup restore`.
  131. #
  132. # NOTE (still true): `pg_dump` CANNOT back up the DoltGres data plane — it opens
  133. # a REPEATABLE READ READ ONLY snapshot txn DoltGres doesn't implement
  134. # ("SET TRANSACTION is not yet supported"). Dolt-native `dolt_backup` is the
  135. # only data-plane backup path; pg_dump is a stock-Postgres control-plane helper.
  136. # ─── briven-engine Auth DB (DOLTGRES ONLY — non-negotiable) ───────────
  137. # HARD RULE: the COMPLETE Briven project is Doltgres. New parts do not get
  138. # a separate stock-Postgres brain. SuperTokens Core Docker is REMOVED —
  139. # it is incompatible with Doltgres (SET SESSION CHARACTERISTICS).
  140. # briven-engine = Briven API code + tables in Doltgres DB `briven_engine`.
  141. # Create/migrate: API `ensureBrivenEngineDatabase` + schema bootstrap.
  142. briven-engine-db-init:
  143. image: dolthub/doltgresql:0.57.2
  144. restart: 'no'
  145. logging: *briven-logging
  146. depends_on:
  147. doltgres:
  148. condition: service_healthy
  149. environment:
  150. PGPASSWORD: ${BRIVEN_DOLTGRES_PASSWORD}
  151. entrypoint:
  152. - /bin/sh
  153. - -c
  154. - |
  155. set -e
  156. echo "briven-engine-db-init: ensuring briven_engine on DOLTGRES only…"
  157. exists=$$(psql -h doltgres -U postgres -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='briven_engine'" || true)
  158. if [ "$$exists" = "1" ]; then
  159. echo "briven_engine already exists on doltgres"
  160. else
  161. psql -h doltgres -U postgres -d postgres -c 'CREATE DATABASE briven_engine'
  162. echo "created briven_engine on doltgres"
  163. fi
  164. networks:
  165. - briven
  166. labels:
  167. - 'briven.service=briven-engine-db-init'
  168. - 'briven.db=doltgres'
  169. # ─── shared infra ─────────────────────────────────────────────────────
  170. redis:
  171. image: redis:7.4-alpine
  172. restart: unless-stopped
  173. logging: *briven-logging
  174. command: redis-server --appendonly yes
  175. volumes:
  176. - redis_data:/data
  177. healthcheck:
  178. test: ['CMD-SHELL', 'redis-cli ping | grep -q PONG']
  179. interval: 10s
  180. timeout: 5s
  181. retries: 5
  182. start_period: 10s
  183. networks:
  184. - briven
  185. labels:
  186. - 'briven_logs=true'
  187. minio:
  188. image: minio/minio:latest
  189. restart: unless-stopped
  190. logging: *briven-logging
  191. command: server /data --console-address ':9001'
  192. environment:
  193. MINIO_ROOT_USER: briven
  194. MINIO_ROOT_PASSWORD: ${BRIVEN_MINIO_ROOT_PASSWORD}
  195. volumes:
  196. - minio_data:/data
  197. healthcheck:
  198. test: ['CMD-SHELL', 'curl -fsS http://localhost:9000/minio/health/live || exit 1']
  199. interval: 15s
  200. timeout: 5s
  201. retries: 5
  202. start_period: 20s
  203. networks:
  204. - briven
  205. - dokploy-network
  206. labels:
  207. - 'briven_logs=true'
  208. - 'traefik.enable=true'
  209. - 'traefik.docker.network=dokploy-network'
  210. # Public S3 endpoint — browsers PUT/GET with sigv4-presigned URLs the
  211. # api mints. The api also reaches MinIO internally at http://minio:9000.
  212. - 'traefik.http.routers.briven-s3.rule=Host(`s3.${BRIVEN_DOMAIN}`)'
  213. - 'traefik.http.routers.briven-s3.entrypoints=websecure'
  214. - 'traefik.http.routers.briven-s3.tls.certresolver=letsencrypt'
  215. - 'traefik.http.routers.briven-s3.service=briven-s3'
  216. - 'traefik.http.services.briven-s3.loadbalancer.server.port=9000'
  217. # One-shot bucket creator. `mc mb --ignore-existing` is idempotent, so this
  218. # runs every deploy and no-ops after the first. restart: 'no' = one-shot, so
  219. # per infra/CLAUDE.md it does NOT need the logging cap.
  220. minio-init:
  221. image: minio/mc:latest
  222. depends_on:
  223. minio:
  224. condition: service_healthy
  225. entrypoint: >
  226. /bin/sh -c "
  227. until /usr/bin/mc alias set minio http://minio:9000 briven ${BRIVEN_MINIO_ROOT_PASSWORD} >/dev/null 2>&1; do
  228. echo 'waiting for minio...'; sleep 2;
  229. done;
  230. /usr/bin/mc mb --ignore-existing minio/${BRIVEN_MINIO_BUCKET:-briven};
  231. echo 'minio bucket ready: ${BRIVEN_MINIO_BUCKET:-briven}';
  232. "
  233. restart: 'no'
  234. networks:
  235. - briven
  236. # ─── application services ─────────────────────────────────────────────
  237. api:
  238. build:
  239. context: ../..
  240. dockerfile: apps/api/Dockerfile
  241. restart: unless-stopped
  242. logging: *briven-logging
  243. depends_on:
  244. postgres:
  245. condition: service_healthy
  246. doltgres:
  247. condition: service_healthy
  248. redis:
  249. condition: service_healthy
  250. briven-engine-db-init:
  251. condition: service_completed_successfully
  252. environment:
  253. BRIVEN_ENV: production
  254. BRIVEN_API_PORT: '3001'
  255. BRIVEN_API_ORIGIN: https://api.${BRIVEN_DOMAIN}
  256. BRIVEN_WEB_ORIGIN: https://${BRIVEN_DOMAIN}
  257. BRIVEN_ADMIN_ORIGIN: https://admin.${BRIVEN_DOMAIN}
  258. # briven-engine = API + Doltgres only (NO SuperTokens Core container).
  259. BRIVEN_AUTH_CORE_ENABLED: ${BRIVEN_AUTH_CORE_ENABLED:-true}
  260. # SQL for Auth vault — ALWAYS Doltgres DB briven_engine (DOLTGRES-FIRST).
  261. BRIVEN_ENGINE_DATABASE_URL: postgres://postgres:${BRIVEN_DOLTGRES_PASSWORD}@doltgres:5432/briven_engine?sslmode=disable
  262. BRIVEN_AUTH_ENABLED: ${BRIVEN_AUTH_ENABLED:-false}
  263. # Observability stack (host-managed compose at /root/briven-observability
  264. # on the France box, same dokploy-network) — powers admin host gauges,
  265. # the live cpu chart, and /v1/admin/timeseries prom-backed series.
  266. BRIVEN_PROMETHEUS_URL: ${BRIVEN_PROMETHEUS_URL:-}
  267. # Hard allowlist: only these emails can EVER be platform admin
  268. # (see apps/api/src/lib/superadmin.ts). Value lives in the Dokploy env.
  269. BRIVEN_SUPERADMIN_EMAILS: ${BRIVEN_SUPERADMIN_EMAILS:-}
  270. BRIVEN_TRUSTED_ORIGINS: https://${BRIVEN_DOMAIN},https://app.${BRIVEN_DOMAIN},https://api.${BRIVEN_DOMAIN},https://admin.${BRIVEN_DOMAIN}
  271. # Control plane — stock Postgres, postgres.js/drizzle.
  272. # Control brain on Doltgres (same cluster as project DBs). Password is
  273. # DOLTGRES, not the legacy stock-Postgres password.
  274. BRIVEN_DATABASE_URL: postgres://postgres:${BRIVEN_DOLTGRES_PASSWORD}@doltgres:5432/briven_control?sslmode=disable
  275. # Data plane — DoltGres, `pg` driver, database-per-project. The api
  276. # connects to the default `postgres` database and CREATEs per-project
  277. # databases on this server.
  278. BRIVEN_DATA_PLANE_URL: postgres://postgres:${BRIVEN_DOLTGRES_PASSWORD}@doltgres:5432/postgres?sslmode=disable
  279. BRIVEN_REDIS_URL: redis://redis:6379
  280. BRIVEN_RUNTIME_URL: http://runtime:3003
  281. # Without this the api falls back to localhost:3004 and can't reach
  282. # realtime — surfaces as realtime_stats_failed "Unable to connect".
  283. BRIVEN_REALTIME_URL: http://realtime:3004
  284. BRIVEN_RUNTIME_SHARED_SECRET: ${BRIVEN_RUNTIME_SHARED_SECRET}
  285. BRIVEN_BETTER_AUTH_SECRET: ${BRIVEN_BETTER_AUTH_SECRET}
  286. BRIVEN_AUDIT_IP_PEPPER: ${BRIVEN_AUDIT_IP_PEPPER}
  287. BRIVEN_ENCRYPTION_KEY: ${BRIVEN_ENCRYPTION_KEY}
  288. # Per-tenant secret-store master key (ARCHITECTURE.md §4/§9).
  289. # BRIVEN_AUTH_ENABLED is set once above with the engine env block.
  290. # Values live in the Dokploy env panel; empty = unset in loadEnv.
  291. BRIVEN_AUTH_MASTER_KEY: ${BRIVEN_AUTH_MASTER_KEY:-}
  292. BRIVEN_MITTERA_API_URL: ${BRIVEN_MITTERA_API_URL:-}
  293. BRIVEN_MITTERA_API_KEY: ${BRIVEN_MITTERA_API_KEY:-}
  294. BRIVEN_MITTERA_WEBHOOK_SECRET: ${BRIVEN_MITTERA_WEBHOOK_SECRET:-}
  295. # Auth OTP / magic-link real inbox: set HOST+USER+PASS(+FROM) for SMTP primary.
  296. # Until SMTP is set, Auth uses mittera (same as platform mail).
  297. BRIVEN_SMTP_HOST: ${BRIVEN_SMTP_HOST:-}
  298. BRIVEN_SMTP_PORT: ${BRIVEN_SMTP_PORT:-587}
  299. BRIVEN_SMTP_USER: ${BRIVEN_SMTP_USER:-}
  300. BRIVEN_SMTP_PASS: ${BRIVEN_SMTP_PASS:-}
  301. BRIVEN_SMTP_FROM: ${BRIVEN_SMTP_FROM:-}
  302. BRIVEN_GOOGLE_CLIENT_ID: ${BRIVEN_GOOGLE_CLIENT_ID:-}
  303. BRIVEN_GOOGLE_CLIENT_SECRET: ${BRIVEN_GOOGLE_CLIENT_SECRET:-}
  304. BRIVEN_GITHUB_CLIENT_ID: ${BRIVEN_GITHUB_CLIENT_ID:-}
  305. BRIVEN_GITHUB_CLIENT_SECRET: ${BRIVEN_GITHUB_CLIENT_SECRET:-}
  306. BRIVEN_KONNOS_CLIENT_ID: ${BRIVEN_KONNOS_CLIENT_ID:-}
  307. BRIVEN_KONNOS_CLIENT_SECRET: ${BRIVEN_KONNOS_CLIENT_SECRET:-}
  308. BRIVEN_KONNOS_ISSUER: ${BRIVEN_KONNOS_ISSUER:-https://code.konnos.org}
  309. BRIVEN_DISCORD_CLIENT_ID: ${BRIVEN_DISCORD_CLIENT_ID:-}
  310. BRIVEN_DISCORD_CLIENT_SECRET: ${BRIVEN_DISCORD_CLIENT_SECRET:-}
  311. BRIVEN_POLAR_API_BASE: ${BRIVEN_POLAR_API_BASE:-https://api.polar.sh}
  312. BRIVEN_POLAR_ACCESS_TOKEN: ${BRIVEN_POLAR_ACCESS_TOKEN:-}
  313. BRIVEN_POLAR_WEBHOOK_SECRET: ${BRIVEN_POLAR_WEBHOOK_SECRET:-}
  314. BRIVEN_POLAR_PRO_PRODUCT_ID: ${BRIVEN_POLAR_PRO_PRODUCT_ID:-}
  315. BRIVEN_POLAR_TEAM_PRODUCT_ID: ${BRIVEN_POLAR_TEAM_PRODUCT_ID:-}
  316. BRIVEN_DOMAIN: ${BRIVEN_DOMAIN}
  317. BRIVEN_OPEN_SIGNUPS: ${BRIVEN_OPEN_SIGNUPS:-false}
  318. BRIVEN_OLLAMA_URL: ${BRIVEN_OLLAMA_URL:-}
  319. BRIVEN_OLLAMA_API_KEY: ${BRIVEN_OLLAMA_API_KEY:-}
  320. BRIVEN_OLLAMA_MODEL: ${BRIVEN_OLLAMA_MODEL:-qwen2.5-coder:32b}
  321. BRIVEN_MINIO_ENDPOINT: http://minio:9000
  322. BRIVEN_MINIO_PUBLIC_ENDPOINT: https://s3.${BRIVEN_DOMAIN}
  323. BRIVEN_MINIO_ACCESS_KEY: briven
  324. BRIVEN_MINIO_SECRET_KEY: ${BRIVEN_MINIO_ROOT_PASSWORD}
  325. BRIVEN_MINIO_BUCKET: ${BRIVEN_MINIO_BUCKET:-briven}
  326. BRIVEN_MINIO_REGION: ${BRIVEN_MINIO_REGION:-us-east-1}
  327. # imgproxy — on-the-fly image transforms (M4). The api mints SIGNED
  328. # imgproxy URLs (services/image-transform.ts). ENDPOINT is the
  329. # media host + the /_t path prefix (imgproxy sits BEHIND media.<domain>
  330. # under PathPrefix(/_t), no new subdomain). image-transform.ts signs the
  331. # path WITHOUT the prefix (/rs:.../g:sm/<b64 source>) and imgproxy strips
  332. # /_t before verifying — the signed portions match. KEY/SALT are the same
  333. # hex secrets the imgproxy container gets; set all three in the Dokploy
  334. # env to turn transforms on (unset => endpoint returns 503, fail-safe).
  335. BRIVEN_IMGPROXY_ENDPOINT: https://media.${BRIVEN_DOMAIN}/_t
  336. BRIVEN_IMGPROXY_KEY: ${BRIVEN_IMGPROXY_KEY:-}
  337. BRIVEN_IMGPROXY_SALT: ${BRIVEN_IMGPROXY_SALT:-}
  338. # Self-hosted MaxMind GeoLite2-City for Auth email Location (city/country).
  339. # Host file: /var/lib/GeoIP/GeoLite2-City.mmdb (bind-mounted below).
  340. BRIVEN_GEOIP_DB_PATH: ${BRIVEN_GEOIP_DB_PATH:-/var/lib/GeoIP/GeoLite2-City.mmdb}
  341. volumes:
  342. # Read-only city DB for Auth email geo (device location line).
  343. - /var/lib/GeoIP:/var/lib/GeoIP:ro
  344. healthcheck:
  345. # /info is documented to never 500 (apps/api/Dockerfile). bun ships in
  346. # the api image and has a built-in fetch.
  347. test: ['CMD-SHELL', "bun -e \"fetch('http://localhost:3001/info').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
  348. interval: 15s
  349. timeout: 5s
  350. retries: 5
  351. start_period: 40s
  352. networks:
  353. - briven
  354. - dokploy-network
  355. labels:
  356. - 'briven_logs=true'
  357. - 'traefik.enable=true'
  358. - 'traefik.docker.network=dokploy-network'
  359. - 'traefik.http.routers.briven-api.rule=Host(`api.${BRIVEN_DOMAIN}`)'
  360. - 'traefik.http.routers.briven-api.entrypoints=websecure'
  361. - 'traefik.http.routers.briven-api.tls.certresolver=letsencrypt'
  362. - 'traefik.http.routers.briven-api.service=briven-api'
  363. - 'traefik.http.services.briven-api.loadbalancer.server.port=3001'
  364. # media.briven.tech -> this api (public file bytes). Explicit .service= on
  365. # every router so Traefik does not treat the container as multi-service.
  366. - 'traefik.http.routers.briven-media.rule=Host(`media.${BRIVEN_DOMAIN}`)'
  367. - 'traefik.http.routers.briven-media.entrypoints=websecure'
  368. - 'traefik.http.routers.briven-media.tls.certresolver=letsencrypt'
  369. - 'traefik.http.routers.briven-media.service=briven-api'
  370. # /_t image transforms: router lives on the imgproxy service (below), not here.
  371. # imgproxy — on-the-fly image transforms (M4). Sits BEHIND media.<domain>
  372. # under the /_t path prefix (no new public subdomain, per the media-host
  373. # rule). The api mints signed URLs; imgproxy fetches the source from the
  374. # PUBLIC media host, resizes, and returns it. SSRF is locked to the media
  375. # host via IMGPROXY_ALLOWED_SOURCES. No host port — only Traefik (on the
  376. # dokploy-network) can reach port 8080.
  377. imgproxy:
  378. image: darthsim/imgproxy:latest
  379. restart: unless-stopped
  380. logging: *briven-logging
  381. environment:
  382. # Signing — MUST equal the api's BRIVEN_IMGPROXY_KEY/SALT (same hex
  383. # secrets, set in the Dokploy env). imgproxy strips IMGPROXY_PATH_PREFIX
  384. # (/_t) from the request path, then verifies the HMAC over the remaining
  385. # /rs:.../g:sm/<b64 source> — exactly what image-transform.ts signed.
  386. IMGPROXY_KEY: ${BRIVEN_IMGPROXY_KEY:-}
  387. IMGPROXY_SALT: ${BRIVEN_IMGPROXY_SALT:-}
  388. IMGPROXY_PATH_PREFIX: /_t
  389. # SSRF guard: imgproxy may ONLY fetch sources from the public media host.
  390. IMGPROXY_ALLOWED_SOURCES: https://media.${BRIVEN_DOMAIN}/
  391. # Sane limits — resize-bomb / oversized-source guards. Format auto-nego:
  392. # serve WebP to browsers that send Accept: image/webp.
  393. IMGPROXY_MAX_SRC_RESOLUTION: '50'
  394. IMGPROXY_ENABLE_WEBP_DETECTION: 'true'
  395. # Bind on 8080 (default) — Traefik reaches it over dokploy-network only.
  396. IMGPROXY_BIND: ':8080'
  397. healthcheck:
  398. # imgproxy ships an /health endpoint that never 500s when the process
  399. # is up. imgproxy has no shell/curl, so use its built-in health probe.
  400. test: ['CMD', 'imgproxy', 'health']
  401. interval: 15s
  402. timeout: 5s
  403. retries: 5
  404. start_period: 20s
  405. networks:
  406. - dokploy-network
  407. labels:
  408. - 'briven_logs=true'
  409. - 'traefik.enable=true'
  410. - 'traefik.docker.network=dokploy-network'
  411. - 'traefik.http.services.briven-imgproxy.loadbalancer.server.port=8080'
  412. # Higher priority than briven-media so /_t/* hits imgproxy; rest of
  413. # media.<domain> stays on the api. IMGPROXY_PATH_PREFIX=/_t strips prefix.
  414. - 'traefik.http.routers.briven-imgt.rule=Host(`media.${BRIVEN_DOMAIN}`) && PathPrefix(`/_t`)'
  415. - 'traefik.http.routers.briven-imgt.priority=100'
  416. - 'traefik.http.routers.briven-imgt.entrypoints=websecure'
  417. - 'traefik.http.routers.briven-imgt.tls.certresolver=letsencrypt'
  418. - 'traefik.http.routers.briven-imgt.service=briven-imgproxy'
  419. runtime:
  420. build:
  421. context: ../..
  422. dockerfile: apps/runtime/Dockerfile
  423. restart: unless-stopped
  424. logging: *briven-logging
  425. depends_on:
  426. api:
  427. condition: service_started
  428. doltgres:
  429. condition: service_healthy
  430. environment:
  431. BRIVEN_ENV: production
  432. BRIVEN_RUNTIME_PORT: '3003'
  433. BRIVEN_RUNTIME_SHARED_SECRET: ${BRIVEN_RUNTIME_SHARED_SECRET}
  434. BRIVEN_RUNTIME_EXECUTOR: deno
  435. BRIVEN_RUNTIME_BUNDLE_DIR: /var/lib/briven/bundles
  436. BRIVEN_API_INTERNAL_URL: http://api:3001
  437. # Data plane — DoltGres (the old BRIVEN_URL mysql:// was wrong, removed).
  438. BRIVEN_DATA_PLANE_URL: postgres://postgres:${BRIVEN_DOLTGRES_PASSWORD}@doltgres:5432/postgres?sslmode=disable
  439. volumes:
  440. - runtime_bundles:/var/lib/briven/bundles
  441. healthcheck:
  442. # Any HTTP response = process is up (port serving).
  443. test: ['CMD-SHELL', "bun -e \"fetch('http://localhost:3003/').then(()=>process.exit(0)).catch(()=>process.exit(1))\""]
  444. interval: 15s
  445. timeout: 5s
  446. retries: 5
  447. start_period: 40s
  448. networks:
  449. - briven
  450. labels:
  451. - 'briven_logs=true'
  452. realtime:
  453. build:
  454. context: ../..
  455. dockerfile: apps/realtime/Dockerfile
  456. restart: unless-stopped
  457. logging: *briven-logging
  458. depends_on:
  459. doltgres:
  460. condition: service_healthy
  461. environment:
  462. BRIVEN_ENV: production
  463. BRIVEN_REALTIME_PORT: '3004'
  464. BRIVEN_API_INTERNAL_URL: http://api:3001
  465. BRIVEN_RUNTIME_SHARED_SECRET: ${BRIVEN_RUNTIME_SHARED_SECRET}
  466. # Data plane — DoltGres. Realtime polls DOLT_HASHOF('HEAD') per project
  467. # (no LISTEN/NOTIFY on DoltGres). The old BRIVEN_URL mysql:// was wrong.
  468. BRIVEN_DATA_PLANE_URL: postgres://postgres:${BRIVEN_DOLTGRES_PASSWORD}@doltgres:5432/postgres?sslmode=disable
  469. BRIVEN_REALTIME_POLL_MS: '500'
  470. healthcheck:
  471. test: ['CMD-SHELL', "bun -e \"fetch('http://localhost:3004/').then(()=>process.exit(0)).catch(()=>process.exit(1))\""]
  472. interval: 15s
  473. timeout: 5s
  474. retries: 5
  475. start_period: 40s
  476. networks:
  477. - briven
  478. - dokploy-network
  479. labels:
  480. - 'briven_logs=true'
  481. - 'traefik.enable=true'
  482. - 'traefik.docker.network=dokploy-network'
  483. - 'traefik.http.routers.briven-realtime.rule=Host(`realtime.${BRIVEN_DOMAIN}`)'
  484. - 'traefik.http.routers.briven-realtime.entrypoints=websecure'
  485. - 'traefik.http.routers.briven-realtime.tls.certresolver=letsencrypt'
  486. - 'traefik.http.services.briven-realtime.loadbalancer.server.port=3004'
  487. web:
  488. build:
  489. context: ../..
  490. dockerfile: apps/web/Dockerfile
  491. restart: unless-stopped
  492. logging: *briven-logging
  493. depends_on:
  494. api:
  495. condition: service_started
  496. environment:
  497. BRIVEN_API_ORIGIN: https://api.${BRIVEN_DOMAIN}
  498. BRIVEN_WEB_ORIGIN: https://${BRIVEN_DOMAIN}
  499. NEXT_PUBLIC_BRIVEN_API_ORIGIN: https://api.${BRIVEN_DOMAIN}
  500. NEXT_PUBLIC_BRIVEN_HAS_GOOGLE_OAUTH: ${BRIVEN_GOOGLE_CLIENT_ID:+true}
  501. NEXT_PUBLIC_BRIVEN_HAS_GITHUB_OAUTH: ${BRIVEN_GITHUB_CLIENT_ID:+true}
  502. NEXT_PUBLIC_BRIVEN_HAS_KONNOS_OAUTH: ${BRIVEN_KONNOS_CLIENT_ID:+true}
  503. NEXT_PUBLIC_BRIVEN_HAS_DISCORD_OAUTH: ${BRIVEN_DISCORD_CLIENT_ID:+true}
  504. healthcheck:
  505. # web runs `next start` on node — use node's built-in fetch.
  506. test: ['CMD-SHELL', "node -e \"fetch('http://localhost:3000/').then(()=>process.exit(0)).catch(()=>process.exit(1))\""]
  507. interval: 15s
  508. timeout: 5s
  509. retries: 5
  510. start_period: 40s
  511. networks:
  512. - briven
  513. - dokploy-network
  514. labels:
  515. - 'briven_logs=true'
  516. - 'traefik.enable=true'
  517. - 'traefik.docker.network=dokploy-network'
  518. - 'traefik.http.routers.briven-web.rule=Host(`${BRIVEN_DOMAIN}`) || Host(`app.${BRIVEN_DOMAIN}`) || Host(`admin.${BRIVEN_DOMAIN}`)'
  519. - 'traefik.http.routers.briven-web.entrypoints=websecure'
  520. - 'traefik.http.routers.briven-web.tls.certresolver=letsencrypt'
  521. - 'traefik.http.routers.briven-web.service=briven-web'
  522. - 'traefik.http.services.briven-web.loadbalancer.server.port=3000'
  523. docs:
  524. build:
  525. context: ../..
  526. dockerfile: apps/docs/Dockerfile
  527. restart: unless-stopped
  528. logging: *briven-logging
  529. depends_on:
  530. api:
  531. condition: service_started
  532. environment:
  533. # Used by /status + /api/status/incidents.xml to read live incidents.
  534. BRIVEN_API_ORIGIN: https://api.${BRIVEN_DOMAIN}
  535. healthcheck:
  536. test: ['CMD-SHELL', "node -e \"fetch('http://localhost:3002/').then(()=>process.exit(0)).catch(()=>process.exit(1))\""]
  537. interval: 15s
  538. timeout: 5s
  539. retries: 5
  540. start_period: 40s
  541. networks:
  542. - briven
  543. - dokploy-network
  544. labels:
  545. - 'briven_logs=true'
  546. - 'traefik.enable=true'
  547. - 'traefik.docker.network=dokploy-network'
  548. - 'traefik.http.routers.briven-docs.rule=Host(`docs.${BRIVEN_DOMAIN}`)'
  549. - 'traefik.http.routers.briven-docs.entrypoints=websecure'
  550. - 'traefik.http.routers.briven-docs.tls.certresolver=letsencrypt'
  551. - 'traefik.http.routers.briven-docs.service=briven-docs'
  552. - 'traefik.http.services.briven-docs.loadbalancer.server.port=3002'
  553. # status.${BRIVEN_DOMAIN} — same docs container; bare `/` rewrites to
  554. # /status. Other paths pass through (so /api/status/incidents.xml works).
  555. - 'traefik.http.routers.briven-status.rule=Host(`status.${BRIVEN_DOMAIN}`)'
  556. - 'traefik.http.routers.briven-status.entrypoints=websecure'
  557. - 'traefik.http.routers.briven-status.tls.certresolver=letsencrypt'
  558. - 'traefik.http.routers.briven-status.service=briven-docs'
  559. - 'traefik.http.routers.briven-status.middlewares=briven-status-rewrite'
  560. - 'traefik.http.middlewares.briven-status-rewrite.replacepathregex.regex=^/$$'
  561. - 'traefik.http.middlewares.briven-status-rewrite.replacepathregex.replacement=/status'
  562. volumes:
  563. postgres_data:
  564. doltgres_data:
  565. doltgres_backups:
  566. redis_data:
  567. minio_data:
  568. runtime_bundles:
  569. networks:
  570. briven:
  571. driver: bridge
  572. # Dokploy's ingress network — Traefik watches this for routing + TLS.
  573. # Routed services (api, realtime, web, docs, s3) attach to it in addition
  574. # to the internal `briven` network; DBs/redis/runtime stay internal-only.
  575. dokploy-network:
  576. external: true