# deploy.sh — what it is and how it behaves An interactive wrapper around the repo's `setup.sh`. Its job: reconcile **host-specific** values in `.env` for THIS host *before* `setup.sh` renders config from them, then bring the stack up in stages. It exists because copying a populated `.env` between hosts silently propagates stale values (see `02-FINDINGS.md`, finding 2/3). ## Flow (what happens on a run) 1. Detect host type (WSL vs native Linux); let user override. 2. Guard: refuse/warn if the active daemon is **Docker Desktop** (bind mounts break under it — see findings). 3. Resolve deployment **type** (menu with descriptions + resource estimates). 4. Resolve `HOST_IP` (internal bind), **router-facing IP+port** (separate — what `bmp server` targets), auth mode, and for `remote` type the central Kafka. 5. On WSL: auto-detect the **Windows LAN IP** via `powershell.exe` interop for the router-facing default (with graceful fallback to a placeholder). 6. **Port-collision preflight** — checks host ports the type will bind (ss/netstat//proc), warns/refuses on conflict. 7. Show a plan; one confirmation. 8. Write reconciled values to `.env`. 9. Clear stale volume handles → run `setup.sh` → verify bind dirs exist → clear handles again → **staged bring-up** → verify. 10. Print post-deploy notes (WSL: netsh portproxy commands; native: firewall + router `bmp server` snippet). ## Deployment types (also in DEPLOYMENT-TYPES.md) - `full-stack` — collector + Kafka + Postgres + Grafana + feeders, one host. - `remote` — collector + local Kafka only, forwards to a central store's Kafka. Needs `--central-kafka HOST:PORT`. No local store. - `central-store` — store + Grafana + feeders, NO local collector; ingest via remotes. Old scope names (`core`/`feeders`/`full`/`standalone`) are accepted as aliases. ## Flags `--wsl|--prod`, `--host-ip`, `--router-ip`, `--router-port` (default **1790**, the IANA BMP port — collector still listens 5000 internally, mapped), `--auth local|authelia`, `--scope full-stack|remote|central-store`, `--central-kafka HOST:PORT`, `--reset`, `--yes`. ## Notes for repo integration - It calls `./setup.sh` and checks its exit status. It does NOT reimplement setup.sh's provisioning — it drives it with correct inputs. - It assumes `.env.example`, `setup.sh`, `docker-compose.yml` are in the same dir. If `setup.sh` key names change, update deploy.sh's `get_env`/`set_env` references. - Router port default was changed to 1790; the lab routers are currently configured to send BMP to **5000**, so until they're reconfigured, deploy with `--router-port 5000` OR update the routers. This is an open decision (see 03-NEXT-STEPS.md).