# Scenario 1: containers, variants A and B (2026-10-05) Phase 2 of [Deployment_Scenarios_PLAN](2026-10-05_Deployment_Scenarios_PLAN.md). Guide: [Scenario 1: containers](../Deployment/Containers/README.md). ## What was added | Area | Content | |---|---| | Variant B (one container per component) | The existing `docker-compose.yml`, extended: host ports `OVPMON_HTTP_PORT` / `OVPMON_VPN_PORT` (defaults 80 and 1194), health checks for all four services. Nothing else changed | | Variant A (all in one container) | `deploy/allinone/` (`Dockerfile`: UI built in a Node 20 stage; Alpine, nginx, supervisord, gunicorn, uvicorn, gatherer, OpenVPN), `entrypoint.sh` (TUN, easy-rsa workspace, NAT without duplicates, nginx config, **explicit database migration before any service**), `supervisord.conf`, `docker-compose.allinone.yml` | | Same data layout | Both variants use the same five named volumes with the same in-container paths: backups are identical and a volume set can be used by either variant (one variant per host: same ports and container names) | | `deploy/docker/install.sh` | `--variant a|b`, preflight, `.env` with a random secret (mode 600), generated administrator password shown once, build, start, health wait, removal of the admin seed from `.env` once a user exists | | `deploy/docker/update.sh` | Phases: preflight, **backup of all volumes** (verified), source update, build (old stack keeps running, current images tagged `:previous`), stop, **database migration as its own step** (`migrate.py --check` / apply / check, abort before start on failure), start with health wait, **automatic rollback** (volumes restored from this run's backup, `:previous` images started); `--rollback` for a manual rollback; last 5 backups kept | | `backup.sh`, `restore.sh`, `lib.sh` | Stand-alone backup (cron friendly) and restore with confirmation; shared functions | | Housekeeping | root `.dockerignore`; `.gitignore` gets `.env`, `backups/`, deploy state files | | Docs | `DOCS/Deployment/Scenario1_Containers.md`; `DOCS/General/Deployment_Docker.md` is now a pointer | ## Verification (real Docker on this host) | Check | Result | |---|---| | `install.sh --variant b` on a clean host state | built, healthy, administrator seed removed, password shown once | | Variant B: PKI init, server config, client, note | all `200`; stack healthy | | `update.sh` variant B on databases without a version (version table and `note` column removed from real data) | backup, migration phase applied the baseline to both databases with their own backups, start healthy, profile and PKI intact | | `update.sh` variant B with a broken new Profiler image (injected syntax error) | build ok, migration ok, start unhealthy, **automatic rollback**: volumes restored, previous images started, healthy, data intact | | `install.sh --variant a` | built and healthy; UI and both APIs through nginx; PKI init, server config, client, note; **OpenVPN started inside the container** (process running) | | `update.sh` variant A on databases without a version | explicit migration phase, healthy, data intact | | `backup.sh`, then a change, then `restore.sh` | archives verified; after the restore the later change is gone and the data is as at backup time | | Cleanup | test projects, volumes, images and files removed; the 8089 stand was restarted on its own volumes, data intact | ## Notes and limits - OpenVPN is not started automatically after a container is recreated (update, rollback): start it from the UI. This was already so; an automatic start when `server.conf` exists is a worthwhile follow-up. - Variant A runs everything as root in one container (as the Profiler container in B); the blast radius is wider than in B. - After a rollback the stack runs from the `:previous` images through a generated override; the next `update.sh` run rebuilds and returns to the normal compose file. - Not tested: `docker-compose` v1, switching a volume set between A and B, adoption of a hand-started B stack by `update.sh`. - Two backups started in the same UTC second collide (the second refuses). - A container is not a production host: run the procedure once on the target host before relying on it. ## Existing installations A stack started by hand (`docker-compose up`) can be adopted: `update.sh --variant b` records its state on the first run. Data stays in the named volumes.