From 08351a09bf9f862fdb54f6b35cef6c73b5e3781e Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Thu, 8 Oct 2026 11:00:04 +0200 Subject: [PATCH] chore(deploy): stack ports as env variables; park-lab moves to art-docker-station MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit art-docker-station already serves :80, so the lab stack could not come up there. HTTP_PORT (Caddy listen), SERVER_PORT (host-net server + advertised device push port) and VISION_HOST_PORT (vision loopback publish) now flow from the stack env through docker-compose.prod.yml; the Caddyfile reads {$HTTP_PORT:80} and {$SERVER_PORT:3000}. Unset = the old :80 -> :3000 / 8089 layout, so booths are unchanged. park-lab: server = art-docker-station, ports 8080 / 3100 / 8189. Verified: caddy validate + adapt (with env -> :8080 / 127.0.0.1:3100, without -> :80 / :3000) and docker compose config with the lab values. Wiki: container-deployment §proxy, fleet-deployment-komodo §park-lab, log. --- Caddyfile | 10 ++++++++-- docker-compose.prod.yml | 16 +++++++++++++--- komodo/resources.toml | 9 ++++++++- wiki/decisions/container-deployment.md | 7 +++++++ wiki/decisions/fleet-deployment-komodo.md | 11 +++++++++++ wiki/log.md | 8 ++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Caddyfile b/Caddyfile index 9b2ab6e..171e692 100644 --- a/Caddyfile +++ b/Caddyfile @@ -7,9 +7,15 @@ # TLS later: replace `:80` with the real hostname (e.g. `parksystems.msai.al`), uncomment # Caddy's :443 in docker-compose.prod.yml, and Caddy auto-provisions HTTPS. For a private # CA / internal cert, use `tls /path/cert.pem /path/key.pem`. -:80 { +# +# PORTS ARE ENV-DRIVEN (2026-10-08): HTTP_PORT (listen, default 80) and SERVER_PORT (upstream, +# default 3000) come from docker-compose.prod.yml, which takes them from the stack env. A booth +# leaves both unset and gets :80 → :3000 exactly as before. A SHARED host (the lab stack moved +# onto art-docker-station, whose :80 belongs to another service) sets HTTP_PORT=8080 etc. in the +# Komodo stack env — nothing here or in the image changes. See wiki/decisions/container-deployment.md. +:{$HTTP_PORT:80} { encode gzip # Host network (prod): the server runs on the host's net namespace (to reach the booth LAN / # device VLAN), so reach it over loopback, not the compose service name `server`. - reverse_proxy 127.0.0.1:3000 + reverse_proxy 127.0.0.1:{$SERVER_PORT:3000} } diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index b35907c..6650fee 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -18,6 +18,13 @@ services: # Host network: Caddy listens on the host's :80 and proxies the host-net server on # 127.0.0.1:3000. (No `ports:` mapping — host mode publishes directly.) network_mode: host + # PORTS (2026-10-08). On a booth nothing is set and the defaults apply (:80 → :3000). On a + # SHARED host — the lab stack runs on art-docker-station, whose :80 is another service's — + # the stack env sets HTTP_PORT / SERVER_PORT / VISION_HOST_PORT and every binding follows. + # The Caddyfile reads these two as {$HTTP_PORT:80} / {$SERVER_PORT:3000}. + environment: + HTTP_PORT: ${HTTP_PORT:-80} + SERVER_PORT: ${SERVER_PORT:-3000} # host mode is mutually exclusive with a named network; the base file doesn't attach proxy, # so nothing to null here (server does — see below). volumes: @@ -45,9 +52,12 @@ services: # host mode is mutually exclusive with a named network — detach the base file's `parking` # attachment (compose errors otherwise: "network_mode and networks cannot both be set"). networks: !reset [] - # Listens on :3000 directly on the host (Caddy proxies it). Loopback to vision: + # Listens on SERVER_PORT (default 3000) directly on the host (Caddy proxies it); the same + # value is what net.ts advertises as the device push port. Loopback to vision on the host + # port vision publishes (VISION_HOST_PORT, default 8089): environment: - VISION_URL: http://127.0.0.1:8089 + PORT: ${SERVER_PORT:-3000} + VISION_URL: http://127.0.0.1:${VISION_HOST_PORT:-8089} # NB: NO `sysctls:` here. net.ipv4.ping_group_range is a per-netns sysctl; under host net # there is no separate namespace, and runc REFUSES it ("not allowed in host network # namespace"). Reader liveness ping uses the HOST's setting instead — the booth host must @@ -95,7 +105,7 @@ services: environment: VISION_RECOGNIZER: fast_alpr ports: - - "127.0.0.1:8089:8089" + - "127.0.0.1:${VISION_HOST_PORT:-8089}:8089" # ≈2 months (see the server note): vision logs less — 20 MB × 10 = 200 MB ceiling. logging: driver: json-file diff --git a/komodo/resources.toml b/komodo/resources.toml index 21df10d..af518d5 100644 --- a/komodo/resources.toml +++ b/komodo/resources.toml @@ -130,7 +130,7 @@ BACKUP_KEY=[[park_2_backup_key]] [[stack]] name = "park-lab" [stack.config] -server = "park-lab" +server = "art-docker-station" git_provider = "git.infra.msai.al" git_account = "komodo" repo = "mca/parking_solution" @@ -146,6 +146,13 @@ REGISTRY=git.infra.msai.al/mca/parking_solution # Lab: pinned to the SAME stage- as the booth whose bug is being reproduced (bump # alongside it). A lab may float, but a reproduction must run the booth's exact image. TAG=stage-88f9c53 +# The lab stack runs on art-docker-station (2026-10-08), a SHARED host: :80 is another service's +# and :3000 / :8089 may be too. These three move every host binding (Caddy listen, host-net +# server, vision loopback publish); the UI is then http://:8080/. Booth stacks leave +# them unset and keep :80 → :3000. See docker-compose.prod.yml + Caddyfile. +HTTP_PORT=8080 +SERVER_PORT=3100 +VISION_HOST_PORT=8189 COOKIE_SECURE=0 # Entitled to Car Wash too, so the wash-desk printer role and till can be exercised on the bench. MODULES_ENTITLED=parking,carwash diff --git a/wiki/decisions/container-deployment.md b/wiki/decisions/container-deployment.md index 31dba36..d5e9dc9 100644 --- a/wiki/decisions/container-deployment.md +++ b/wiki/decisions/container-deployment.md @@ -121,6 +121,13 @@ prod); `ENV=dev` switches to the dev override. internal); `/api/ws` upgrades pass through. `Caddyfile` binds `:80` so it matches ANY host — booth IP, localhost, or `parksystems.msai.al` (pointed at the booth IP via hosts/DNS on-site). TLS later: swap `:80` for the real hostname + uncomment Caddy `:443` → auto-HTTPS. + **Ports are stack-env variables since 2026-10-08**: `HTTP_PORT` (Caddy listen, default 80), + `SERVER_PORT` (host-net server + the advertised device push port, default 3000) and + `VISION_HOST_PORT` (vision's loopback publish, default 8089). The Caddyfile reads the first two + as `{$HTTP_PORT:80}` / `{$SERVER_PORT:3000}`, so a booth with nothing set is byte-for-byte the + old `:80 → :3000`. Introduced because the **lab stack moved onto `art-docker-station`**, a shared + host whose `:80` belongs to another service — the `park-lab` stack env sets 8080 / 3100 / 8189 + ([[fleet-deployment-komodo]]). Same-origin WS passes on any port (host header includes it). - `WS_ALLOWED_ORIGINS` (env) must list any REMOTE origin admins use (same-origin always passes). ## Invariants (must hold) diff --git a/wiki/decisions/fleet-deployment-komodo.md b/wiki/decisions/fleet-deployment-komodo.md index dd5cbe3..8239e05 100644 --- a/wiki/decisions/fleet-deployment-komodo.md +++ b/wiki/decisions/fleet-deployment-komodo.md @@ -193,6 +193,17 @@ publish. ## park-lab — the lab bench joins the fleet (2026-07-07) +> **2026-10-08 — park-lab now runs on `art-docker-station`** (`server = "art-docker-station"`, +> the same Periphery that hosts `wash-collector`), so the app can be exercised without the lab +> box. That host's `:80` is taken, so the stack env sets **`HTTP_PORT=8080`, `SERVER_PORT=3100`, +> `VISION_HOST_PORT=8189`** — three new variables honoured by `docker-compose.prod.yml` and the +> Caddyfile ([[container-deployment]] §proxy); booths leave them unset. The UI is +> `http://:8080/`. Caveats of a shared host: the server still runs on the HOST network +> (it sees the station's LAN, not a device VLAN — device I/O is not testable there, only the app), +> the `parking-data` volume is per-stack (`park-lab_parking-data`), and the USB-printer +> `/dev/usb` bind still applies: if the station has no `/dev/usb`, Docker creates it as an empty +> directory on first start (harmless — the printer simply probes "offline"). + Second `[[stack]]` in `komodo/resources.toml`: **`park-lab`** (server = the lab box's Periphery `connect_as`), the first non-booth member and the proof of the tier model in practice: diff --git a/wiki/log.md b/wiki/log.md index 56790de..3f40fba 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3371,3 +3371,11 @@ run against the real IPC-HFW2549T: snapshot 273 KB, a 2 h-off sync set and read stamped on receipt. Still open: the server-side attach subscriber, and whether SMD emits `SmartMotionVehicle` in addition to / instead of `VideoMotion`. Pages: [[dahua-ipc-hfw2549t]], [[lpr-camera]], [[site-device-installation]] §3, [[index]]. + +## 2026-10-08 — park-lab moves to art-docker-station; stack ports become env variables + +The lab stack's Periphery is now the shared `art-docker-station`, whose `:80` is another +service's. `HTTP_PORT` / `SERVER_PORT` / `VISION_HOST_PORT` now flow from the stack env through +`docker-compose.prod.yml` into Caddy (`{$HTTP_PORT:80}` / `{$SERVER_PORT:3000}`), the host-net +server (`PORT`) and vision's loopback publish; defaults reproduce the booth layout exactly. park-lab +sets 8080 / 3100 / 8189. Pages: [[container-deployment]], [[fleet-deployment-komodo]] §park-lab.