38 lines
3.4 KiB
Markdown
38 lines
3.4 KiB
Markdown
---
|
|
type: entity
|
|
updated: 2026-07-12
|
|
tags: [deployment, ci-cd, docker, komodo, traefik]
|
|
---
|
|
|
|
# Deployment — Docker / Gitea CI / Komodo / Traefik
|
|
|
|
How the [[backend]] (+ built [[frontend]]) ships to production. Added 2026-07-12; ⚠️ pipeline authored but the first run through the Gitea runner is still pending (no Docker on the dev machine — the runner is the first place the image actually builds).
|
|
|
|
## Shape
|
|
|
|
One image, one container, one stack:
|
|
|
|
- **`Dockerfile`** (repo root) — two stages: `node:24-alpine` runs `npm ci && npm run build` in `frontend/`, then `python:3.13-slim` installs `backend/requirements.txt`, copies `backend/` + the built `dist/` to where `backend/main.py` expects it (`/app/frontend/dist`). Runs as UID 1000 under tini, `CMD python -m backend.main`.
|
|
- **State on a volume**: `BACKEND_DB=/data/backend.db` and `BACKEND_EVENTS=/data/events.jsonl` env overrides (the latter added 2026-07-12 to `journal.py`, mirroring the existing `store.py` override) put all mutable state on the `artiot-data` volume — the container is disposable.
|
|
- **`compose.yaml`** — the Komodo-managed stack. Env-tunable: `ARTIOT_TAG` (default `main`; set a commit SHA to pin/rollback), `ARTIOT_HOST`, `TRAEFIK_NETWORK` (default `traefik`), `ARTIOT_ENTRYPOINT` (`websecure`), `ARTIOT_CERTRESOLVER` (`letsencrypt`).
|
|
- **`GET /api/health`** — unauthenticated liveness probe (added 2026-07-12) used by the Docker healthcheck; also handy for Traefik/Komodo.
|
|
|
|
## Two front doors, same port
|
|
|
|
| Door | Path | Why |
|
|
|---|---|---|
|
|
| Charger | `ws://<docker-host>:9000/<ChargerID>` — **published port, no proxy** | The URL is hardcoded in the charger touchscreen (change = power-cycle, [[troubleshooting]] #4) and the [[jc-6620|JC-6620]] speaks plain `ws://` — no TLS, no SNI, nothing for Traefik to route on. Docker host needs a DHCP reservation at the IP the charger dials. |
|
|
| Humans | `https://$ARTIOT_HOST` via Traefik labels | Panel with TLS; same container port 9000. |
|
|
|
|
## CI (`.gitea/workflows/build.yml`)
|
|
|
|
Mirrors the polymarket-bot repo's pattern. On push to `main` (paths-filtered): plain `docker build` → **smoke test gate** (`backend/smoke_test.py`, 65 checks — REST auth/scopes, per-gun cards, pending-card workflow, OCPP WS round-trips via a fake charge point, session store, SPA serving; in-process against a temp db, promoted into the repo 2026-07-12) → push `git.infra.msai.al/art/charging_station:{main,<sha>}` → HMAC-signed Komodo stack redeploy webhook. A failed smoke test means the image is never pushed.
|
|
|
|
Repo secrets required: `REGISTRY_USERNAME`, `REGISTRY_PASSWORD`, `KOMODO_STACK_WEBHOOK_URL`, `KOMODO_WEBHOOK_SECRET`.
|
|
|
|
## Migration & constraints
|
|
|
|
- **Moving the existing install**: copy the current `backend/backend.db` into the volume (`docker compose cp backend/backend.db artiot:/data/backend.db`, restart) — users, cards, sessions, and the session-signing secret all ride along, so nobody re-logs-in. Fresh install instead: `docker compose exec artiot python -m backend.users add <name> --scopes admin`.
|
|
- **Charger reachability**: today the charger dials `10.0.10.203:9000` — either the Docker host takes over that address or the touchscreen URL changes (power-cycle). ❓ ties into the always-on-host decision in [[overview]].
|
|
- **Relay reachability**: [[wifi-relays|tinytuya]] is plain TCP to the relay IPs — the Docker host's network must reach that subnet (bridge networking is fine; device discovery by broadcast is not needed once IPs are registered).
|