1a8e2cbb21
Add a Caddy reverse proxy behind a new `--profile serve-static` so a contributor can exercise the production build with the per-locale routing that the on-prem reverse proxy will use (ADR-0019). Closes the gap PR #96 surfaced: the locale switcher / route fusion / cookie plumbing all need a prod-faithful local setup, and `nx serve-static` falls short (no SPA fallback per locale, no smart `/` redirect). What lands: - `infra/local/Caddyfile` — three-block route: * `GET /` → smart redirect to `/{locale}/` based on `Accept-Language` (FR fallback, since the APF audience is francophone). Cookie support waits on the BFF route in ADR-0019. * `/fr/*` → serves `dist/.../browser/fr/` with SPA fallback to `index.html` for deep links. * `/en/*` → mirror. * Catch-all → bounces to `/fr/` so a typo can't land on the Caddy directory-listing footgun (same family as the perf-gate fix in #92). - `infra/local/dev.compose.yml` — new `serve-static` service on the `serve-static` profile, bind-mounting the Caddyfile and the `dist/apps/portal-shell/browser/` folder (read-only). Default port 4200, override via `SERVE_STATIC_PORT` in `.env`. - `infra/local/.env.example` — adds `SERVE_STATIC_PORT=4200`. - `infra/local/dev.sh` — registers `serve-static` in `ALL_PROFILES` so `dev.sh down|status|logs` catches the new container, and `dev.sh up serve-static` works. - `infra/README.md` — adds the new file row, the workflow in the "First-time setup" snippet, the cheat-sheet row, and the service endpoint row with the prerequisite `nx build … -c=production`. Workflow once merged: ``` pnpm exec nx build portal-shell --configuration=production ./infra/local/dev.sh up serve-static open http://localhost:4200/ # → /fr/ or /en/ per Accept-Language ``` Verified locally: - GET / with Accept-Language=fr → 302 /fr/ - GET / with Accept-Language=en → 302 /en/ - GET /unknown → 302 /fr/ - GET /fr/deep/route → 200 (SPA fallback to fr/index.html) - GET /fr/favicons/favicon.svg → 200 (per-locale asset served) - /fr/index.html has `lang="fr"` and `<base href="/fr/">` - /en/index.html has `lang="en"` and `<base href="/en/">` This is local convenience only — no TLS, no auth, binds to localhost. The on-prem reverse proxy gets its own ADR (phase 3b).
38 lines
1.3 KiB
Bash
38 lines
1.3 KiB
Bash
# Local-dev secrets and ports for `infra/local/dev.compose.yml`.
|
|
# Copy to `.env` (which is git-ignored) and adjust as needed.
|
|
#
|
|
# cp .env.example .env
|
|
# $EDITOR .env
|
|
|
|
# ---------------------------------------------------------------- Postgres
|
|
# `POSTGRES_PASSWORD` is mandatory — the compose refuses to boot
|
|
# without it.
|
|
#
|
|
# Picking a password — keep it URL-safe in dev. The BFF reads its
|
|
# Postgres URL via `DATABASE_URL` and Prisma demands the URL form;
|
|
# any `@`, `#`, `:`, `/`, `?`, `%`, `&`, `=`, `+`, `;` in the
|
|
# password must be URL-encoded in `apps/portal-bff/.env`. Easiest
|
|
# avoided by sticking to alphanumerics + `-_.~` in dev.
|
|
POSTGRES_USER=portal
|
|
POSTGRES_PASSWORD=portal_dev_change_me
|
|
POSTGRES_DB=portal_dev
|
|
POSTGRES_PORT=5432
|
|
|
|
# ---------------------------------------------------------------- Redis
|
|
# Same — mandatory.
|
|
REDIS_PASSWORD=redis_dev_change_me
|
|
REDIS_PORT=6379
|
|
|
|
# ---------------------------------------------------------------- OTel
|
|
OTEL_GRPC_PORT=4317
|
|
OTEL_HTTP_PORT=4318
|
|
|
|
# ---------------------------------------------------------------- Optional viewers / tooling
|
|
# Only consumed when the matching Compose profile is activated:
|
|
# --profile dbtools → pgweb
|
|
# --profile observability → Jaeger UI
|
|
# --profile serve-static → Caddy serving the production build
|
|
PGWEB_PORT=8081
|
|
JAEGER_UI_PORT=16686
|
|
SERVE_STATIC_PORT=4200
|