fix(deploy): isolate web→api traffic on a private network

nginx proxied to `api:4100` over the shared `dokploy-network`, where the
generic name `api` resolved to more than one container (a stale one from a
previous deploy, or another project's service). nginx pinned those IPs at
startup and round-robined across them, so requests hit a refused upstream
and could reach a foreign container.

- api now lives only on a stack-private `internal` network, aliased as
  `superlist-api`; only web joins `dokploy-network` for Traefik.
- nginx proxies via a variable with Docker's resolver (127.0.0.11,
  valid=10s), so API redeploys never leave it on a stale IP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-19 12:05:20 -03:00
parent 371e59de92
commit 815dcc300d
4 changed files with 31 additions and 11 deletions

View File

@@ -90,10 +90,13 @@ Run from the repo root. Verification order is `build`, then `lint` → `typechec
rename never changes the TypeScript API. Default constraint/index names follow the mapped names, so do not
set `map:` unless you have a reason to.
- **Deployment: Docker Compose on Dokploy** (`docker-compose.yml` at the repo root). Two services, `api` and
`web`; the database is external (Dokploy's), and both join the external `dokploy-network` for Traefik. The
`web`; the database is external (Dokploy's). Only `web` joins the external `dokploy-network` for Traefik;
`web` and `api` share the stack-private `internal` network, where the API has the alias `superlist-api`
(never rely on a generic service name on the shared network: other projects can answer to it). The
`api` image (`apps/api/Dockerfile`) builds the Bun bundle and runs `prisma migrate deploy` before
`bun run start`; the `web` image (`apps/web/Dockerfile`) builds with Vite and serves `dist/` with
`apps/web/nginx.conf`, which also proxies `/api/*` to `http://api:4100`. Required env vars are interpolated
`apps/web/nginx.conf`, which also proxies `/api/*` to `http://superlist-api:4100` (re-resolved through
Docker's DNS, so API redeploys don't leave nginx on a stale IP). Required env vars are interpolated
by Compose (`DATABASE_URL`, `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `CORS_ORIGIN`, `WEB_APP_URL`); set them
in Dokploy. There is no hosted CI.
- Generated files are gitignored and must never be edited by hand: `apps/web/src/routeTree.gen.ts`,