From 2a8f875a9c0da76bcd61b54893fa0177d3a6821e Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Mon, 1 Jun 2026 13:02:25 +0200 Subject: [PATCH] fix(infra): exclude serve-static from 'dev.sh up all' (port collision with apps) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dev.sh up all failed at startup with 'port 4200 already allocated': both the apps profile (portal-shell dev-server, ADR-0030) and the serve-static profile (Caddy reverse proxy) publish 4200 by default. Split ALL_PROFILES (teardown / status / logs scope, unchanged) from a new UP_ALL_PROFILES (what 'up all' expands to). serve-static drops out of up all because: - it collides with apps on 4200, and - it has zero value without a prior nx build --configuration=production (otherwise Caddy 404s every request). serve-static stays explicit: ./infra/local/dev.sh up serve-static. Teardown still catches it via ALL_PROFILES. Usage text + infra/README.md cheat-sheet updated. The script is environment-agnostic — works the same on local and on vm-dev. No local-vs-vm mode needed. --- infra/README.md | 28 ++++++++++++++-------------- infra/local/dev.sh | 25 +++++++++++++++++++++---- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/infra/README.md b/infra/README.md index bedc9bb..87340bd 100644 --- a/infra/README.md +++ b/infra/README.md @@ -186,20 +186,20 @@ $EDITOR infra/local/.env Run `./infra/local/dev.sh help` for the full reference. Cheat-sheet: -| Command | Effect | -| ------------------------------------------------------------------------------- | ------------------------------------------------------------ | -| `./infra/local/dev.sh up` | Core only (postgres + redis + otel-collector) | -| `./infra/local/dev.sh up all` | Core + every profile | -| `./infra/local/dev.sh up dbtools` | Core + pgweb | -| `./infra/local/dev.sh up observability` | Core + Jaeger | -| `./infra/local/dev.sh up serve-static` | Core + Caddy serving `dist/.../browser/` per ADR-0019 | -| `./infra/local/dev.sh up apps` | Core + the three Nx dev servers in Docker (ADR-0030) | -| `./infra/local/dev.sh down` | Tear down the whole stack (every profile in scope) | -| `./infra/local/dev.sh down -v` | Tear down + wipe named volumes (incl. audit-roles bootstrap) | -| `./infra/local/dev.sh stop pgweb` | Stop one service (containers stay around) | -| `./infra/local/dev.sh status` | `docker compose ps`, with every profile visible | -| `./infra/local/dev.sh logs otel-collector` | Follow logs | -| `./infra/local/dev.sh exec postgres psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"` | Run a command inside a service | +| Command | Effect | +| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| `./infra/local/dev.sh up` | Core only (postgres + redis + otel-collector) | +| `./infra/local/dev.sh up all` | Core + dbtools + observability + apps (full dev stack). serve-static is excluded — it would collide with apps on port 4200 | +| `./infra/local/dev.sh up dbtools` | Core + pgweb | +| `./infra/local/dev.sh up observability` | Core + Jaeger | +| `./infra/local/dev.sh up serve-static` | Core + Caddy serving `dist/.../browser/` per ADR-0019 | +| `./infra/local/dev.sh up apps` | Core + the three Nx dev servers in Docker (ADR-0030) | +| `./infra/local/dev.sh down` | Tear down the whole stack (every profile in scope) | +| `./infra/local/dev.sh down -v` | Tear down + wipe named volumes (incl. audit-roles bootstrap) | +| `./infra/local/dev.sh stop pgweb` | Stop one service (containers stay around) | +| `./infra/local/dev.sh status` | `docker compose ps`, with every profile visible | +| `./infra/local/dev.sh logs otel-collector` | Follow logs | +| `./infra/local/dev.sh exec postgres psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"` | Run a command inside a service | Anything not matching one of the named verbs is passed through to `docker compose -f dev.compose.yml ...` (with every profile flagged in), so you keep the full Compose surface available — `./dev.sh config`, `./dev.sh top`, `./dev.sh inspect …`, etc. diff --git a/infra/local/dev.sh b/infra/local/dev.sh index febaa77..51a2d82 100755 --- a/infra/local/dev.sh +++ b/infra/local/dev.sh @@ -14,10 +14,23 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" COMPOSE_FILE="${SCRIPT_DIR}/dev.compose.yml" -# Profiles defined in dev.compose.yml. Keep in sync if a new profile -# is added. +# Every profile defined in dev.compose.yml, used as the teardown / +# status / logs scope so a profile started under a custom flag is +# always reachable later. Keep in sync if a new profile is added. ALL_PROFILES=(dbtools observability serve-static apps) +# What `up all` expands to — everything you want running for a full +# dev session. `serve-static` is deliberately excluded: +# - it would collide with `apps` on host port 4200 (both publish the +# SPA there by default — Caddy serves the production build, the +# `apps` profile runs the Angular dev-server); +# - without a prior `nx build --configuration=production`, Caddy +# just 404s every request, so it adds nothing to a comprehensive +# `up all` invocation. Users who actually need it run +# `./infra/local/dev.sh up serve-static` (and `down` still tears +# it down because it's in ALL_PROFILES above). +UP_ALL_PROFILES=(dbtools observability apps) + # Build "--profile p1 --profile p2 …" as separate arguments. build_all_profile_flags() { local p @@ -56,7 +69,11 @@ Commands: up [target...] Bring up the stack. Targets: (none) core only (postgres + redis + otel-collector) - all core + all profiles + all core + dbtools + observability + apps — + the full dev stack. serve-static is + EXCLUDED because it collides with apps + on port 4200; run it explicitly when + you actually want to serve a prod build. dbtools core + pgweb observability core + jaeger serve-static core + caddy (production-build reverse proxy) @@ -119,7 +136,7 @@ case "$cmd" in if [[ $# -eq 0 ]]; then dc_core up -d elif [[ "$1" == "all" ]]; then - dc_all up -d + up_with_profiles "${UP_ALL_PROFILES[@]}" else up_with_profiles "$@" fi -- 2.30.2