mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-04 17:18:35 +02:00
Addresses review feedback on #6168. The first round's root-cause claim was wrong. It said `BACKEND_PORT=9100 make selfhost` published on 9100 while the health check probed 8080. It does not: when make drives Compose, Compose inherits make's exported values, so both sides agree on 8080 and the override is silently dropped instead. Re-measured through the real recipe, the genuine disagreements were: - `.env` setting PORT with no BACKEND_PORT: probe followed PORT, Compose published ${BACKEND_PORT:-8080} — 9100 vs 8080. - `make selfhost PORT=8080` over a .env with BACKEND_PORT=9100: probe 8080, Compose published 9100. Both are the "wrong port variable" defect the GitHub issue names, and reading the port back from Compose fixes both. The comments and PR text that blamed make/Compose precedence are corrected. The PORT fallback added to docker-compose.selfhost.yml was also unreachable: .env.example shipped BACKEND_PORT=8080 uncommented, so the fallback never engaged and `SELF_HOSTING_AI.md`'s "edit PORT and FRONTEND_PORT" instruction did nothing. Pick one contract and apply it everywhere: PORT is the backend port to edit, BACKEND_PORT/API_PORT/SERVER_PORT are optional aliases that override it. That is already what Makefile, scripts/local-env.sh, scripts/install.sh and install.ps1 do; compose and the web dev fallback were the outliers. - .env.example ships BACKEND_PORT commented out, like its sibling aliases, so editing PORT works out of the box. - apps/web/config/runtime-urls.ts walks the same alias chain instead of reading BACKEND_PORT alone, so `pnpm dev` follows an edited PORT. - SELF_HOSTING_AI.md and SELF_HOSTING_ADVANCED.md state the contract. Configuration that cannot take effect is now reported instead of ignored. scripts/selfhost-preflight.sh warns when an alias in the env file overrides an edited PORT, and when a port from the shell environment is overridden by the env file. The Makefile captures the pristine origins before its include, because afterwards there is no way to tell that `PORT=9000 make selfhost` was asked for. Tests now cross environment -> make -> compose -> report for real. The docker stub is no longer told what to publish: on `up` it asks the real `docker compose config` to interpolate the compose file with the environment the recipe actually handed it, records that, and answers `port` from the recording. Verified failing on the old code — with the old recipe and compose file the suite reports published 8080 against probe 9100, the exact defect. Co-authored-by: multica-agent <github@multica.ai>