Files
OpenVPN-Monitoring-Simple/DOCS/Changes/2026-10-05_UI_Delivery_PLAN.md
ayurishchevandClaude Sonnet 5.5 8371d889a4 Native install: mandatory install directory, UI delivered from the repository
- install.sh always asks for the install directory (--prefix or a prompt
  with confirmation, no default); refuses system directories, the
  repository checkout itself, paths inside/containing it and non-empty
  directories (a resumed install is allowed). A preflight refusal says
  nothing was changed.
- UI is part of the repository: committed build in deploy/ui-dist with
  SOURCE_HASH and a staleness guard (check-ui.sh, loud warning). install.sh
  and update.sh resolve the UI: --ui-dist FILE|DIR, --build-ui, committed
  build; install stops without a UI unless --no-ui. update.sh swaps the UI
  when its hash differs from the installed one (.ui-source-hash).
- build-ui.sh: --docker, --local (host Node >= 20.19, temporary copy),
  --node-download (portable Node, SHA-256 verified), --publish.
- Verified on Alpine 3.23: install without UI options installs the real UI;
  local build equals the Docker build; update skips an unchanged UI and
  warns on a stale build. --node-download is untested (needs network).
- Docs: Scenario 2 guide, change summary, plan, README.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-05 12:38:18 +03:00

4.0 KiB

UI delivery for system-service installs: plan (2026-10-05)

Problem: install.sh without --ui-dist installed only a placeholder page and merely warned. After the install "the UI is not there". The owner proposes two ways, both wanted:

  1. Keep an up-to-date UI build in the repository and use it at install time.
  2. Allow building the UI without a container.

The install script must treat the UI as a normal part of the repository and install it automatically.

Design

Committed build (deploy/ui-dist/)

  • The built UI (index.html, assets, ...) is committed in deploy/ui-dist/ together with SOURCE_HASH: a SHA-256 over the UI sources it was built from (APP_UI/src, public, index.html, package.json, package-lock.json, vite.config.js, jsconfig.json; sorted, LC_ALL=C). It sits outside APP_UI so the container builds (which copy APP_UI) are not affected.
  • Staleness guard: install and update compare the hash of the current APP_UI sources with SOURCE_HASH. Equal = fresh. Different = the build is older than the sources: a loud warning, the build is still used unless a better source is selected (see order). deploy/native/check-ui.sh exits 1 when the committed build is stale (for maintainers, before a commit or a release).
  • The installed web root records the hash it was installed from (<webroot>/.ui-source-hash), so update.sh knows when the UI changed.

Building without a container

build-ui.sh modes (default: Docker if available, otherwise local):

  • --docker: as now (node:20-alpine).
  • --local: Node on the build host. Uses the system Node when it is 20.19 or newer; otherwise it stops with exact instructions per OS (Alpine: apk add nodejs npm; Debian/Ubuntu: Node 20+ from the Node.js distribution) or, with --node-download, fetches the official Node 20 LTS archive (glibc, x86_64/aarch64) into a temporary directory, verifies it against the published SHA-256 sums, builds and deletes it again (nothing is installed on the host).
  • --publish: after the build, refresh deploy/ui-dist/ and SOURCE_HASH in the repository (maintainer action); -o FILE still writes a tarball for another host.

UI source order in install.sh and update.sh

  1. --ui-dist FILE|DIR (tarball or directory), explicit.
  2. --build-ui (build now from APP_UI, Docker or local as above; for hosts where the committed build is stale or missing).
  3. The committed deploy/ui-dist/ found in the repository checkout (automatic).
  4. Nothing found: install stops with the reasons and the ways out, unless --no-ui is given (placeholder page on purpose). update.sh keeps the installed UI when no source is found. update.sh installs the repository build automatically when its hash differs from the installed one; --ui-dist and --build-ui still override.

Steps

  1. deploy/native/lib.sh: ui_source_hash, ui_resolve (the order above), stage_ui accepting a directory as well as a tarball, hash file in the web root.
  2. deploy/native/build-ui.sh: --docker, --local, --node-download, --publish; Node version check.
  3. deploy/native/check-ui.sh.
  4. install.sh and update.sh use ui_resolve; new options --build-ui, --no-ui; clear messages.
  5. Commit the current build in deploy/ui-dist/ (built with build-ui.sh --publish); .gitignore, .dockerignore adjustments.
  6. Documentation: Scenario 2 guide (UI section rewritten: three ways, staleness, maintainer routine), README quick start, change summary.

Verification

  • check-ui.sh on a fresh and on a deliberately stale tree.
  • build-ui.sh --local on an Alpine container with the distribution's Node (no Docker inside), and --publish with Docker.
  • Alpine install in a container without any UI option: the UI is installed automatically from the repository and served (HTTP 200, real index page, not the placeholder).
  • Update with an unchanged and with a changed UI hash.

Out of scope

CI that rebuilds the UI on every commit, a pre-commit hook, Node installation through the package manager by the scripts.