MC/website/docs/CP-V2-PREVIEW-PUBLICATION.md
Dev 6deb4a2e7d DuneRealms V2 clean baseline
Owner-authorised history reset; current source tree preserved exactly.
2026-11-13 00:05:14 +01:00

5.1 KiB

CP V2 preview publication

The legacy promotion script exits before its PM2 restart steps because that path caused repeated public 502s. Leave that guard in place. A separate live rollout switched the control-panel upstream to an already running release process while this fallback was being prepared. Preserve that active rollout mechanism; the static-only alternative below is prepared and tested but is not the active public route.

Verified rollout checkpoint

Revision 7cb0b29a8670eaac36138deb111677c2c879ea42 passed main CI and the website release builder. The live nginx control-panel upstream changed independently from port 3003 through 3103 to 3203, backed by separate immutable release processes. Concurrent-content guards prevented this work from overwriting that newer nginx configuration. The new V2 modules now return 401 for an unsigned request and the removed DuneGit module returns 404. Public website and V1 panel health remained available.

The additional dunerealms-cpv2-preview.path watcher created for this fallback was disabled and stopped after the active rollout was verified. Its nginx fragment was never included and no nginx reload was performed by this fallback. The approved static snapshot and source files are retained for recovery and review. Do not enable the alternative automatically or compete with the active publication path.

Release flow

  1. Code, local tests, review, commit and push.
  2. Run the existing web CI on the feature branch. The main-only deployment step stays skipped.
  3. Merge only the tested commit. Main CI and the existing release builder must pass.
  4. The release builder records matching built-commit and pending-commit values and an immutable website artifact.
  5. dunerealms-cpv2-preview.path watches the completed-build marker and runs the static publisher. It validates the revision, source paths, file types, size bounds, required files and local imports. DuneGit assets are rejected.
  6. The publisher creates a root-owned immutable preview release, preserves the prior pointer and atomically switches only /var/lib/dunerealms-cp-v2/current.

The preview nginx location serves only /v2/. Its internal authorization subrequest goes directly to the existing panel's owner-protected stylesheet route on loopback port 3003, forwarding the existing session cookie. Guests receive 401 and non-owners receive 403. Other website, API and V1 routes are not redirected to a new application.

One-time activation

After CI approval, install the reviewed publisher and unit files from the approved artifact. The publisher is /usr/local/lib/dunerealms-publish-cpv2.mjs; the matching .service and .path units belong in /etc/systemd/system. Create the root-owned preview state directory. Reload systemd's unit definitions, enable the new path watcher and run the new static publication unit once to consume the already completed build. None of these operations restart the application services.

Install website/ops/cp-v2-preview.nginx.conf as a root-owned include and add it only to the control-panel TLS server block. Preserve the prior config, validate the complete nginx configuration and use one graceful nginx reload after validation. Subsequent approved preview updates switch static files and require no reload.

Do not activate an untested nginx fragment or copy V2 assets directly into the active V1 release. Do not remove the legacy promotion guard. The publisher must not execute repository code, connect to a database, alter process-manager state or accept caller-selected revision paths.

API availability

The static preview uses the currently running API service. A source contract in a newly built release is not proof that the live API has that route. Missing read views return an explicit integration placeholder. Existing company registration, account search and CEO appointment remain on their existing route and authorization policy. If company listing is not available, verified operators can still use a known company reference, matching the existing API contract.

Follow CP-V2-API-INTEGRATION.md for company contracts and missing roles, settings and reporting services. Do not activate new backend services merely to fill a placeholder.

Validation and fallback

The publisher tests run in ordinary website CI. Linux exercises atomic links, immutable release verification and fallback preservation. The isolated nginx test runs as an unprivileged Linux user with temporary assets, a fixture-only authorization backend and separate high ports; it never changes the real nginx configuration.

After activation, verify the current manifest revision and source hashes, confirm the preview is still denied without a session, confirm new module paths are protected, confirm the DuneGit path stays unavailable and check the public website and V1 panel health. Compare the application process IDs before and after; publication must not change them.

For a static release rollback, atomically repoint current to the already retained previous release. No application restart is required. For a configuration rollback, restore the preserved nginx config, validate it and gracefully reload nginx. Keep prior releases for review and manual recovery.