170 lines
9.5 KiB
Markdown
170 lines
9.5 KiB
Markdown
# Deployment
|
|
|
|
## Status and authorization
|
|
|
|
The implementation in PR #59 is not merged, installed, or exercised against
|
|
the VPS. No release, backup, restore, or production service operation has been
|
|
performed by this change. Production deployment remains blocked until the
|
|
owner has verified host state, registry access, protected configuration,
|
|
corpus/index readiness, RU/KY canaries, an external backup, and restore on a
|
|
separate target. See [current state](CURRENT_STATE.md) and the
|
|
[owner evidence packet](DEPLOYMENT_OWNER_PACKET.md).
|
|
|
|
The existing `codex` account has no Docker socket access and receives no new
|
|
privilege in this change. The external receiver requires an owner-controlled
|
|
SSH entry that runs the fixed root command; no SSH key, `authorized_keys`
|
|
entry, sudo rule, or root alias is created here. If `akyldash_vps` logs in as
|
|
`codex`, it cannot run the root-only receiver and the client fails closed.
|
|
Do not grant general sudo or Docker access to make the flow work.
|
|
|
|
## Release verification and image publication
|
|
|
|
`.gitea/workflows/ci.yaml` remains the required test and image-build workflow.
|
|
The release workflow runs after successful main CI, verifies the source run and
|
|
commit, and publishes digest-pinned images plus a small release descriptor.
|
|
The descriptor records both the release workflow run ID and the successful CI
|
|
source run ID. PR builds do not publish images. Production runtime secrets are
|
|
not supplied to CI.
|
|
|
|
On the host, the fixed root receiver uses the installed `gitea-api` helper to
|
|
re-fetch and verify the exact successful CI and release runs, current `main`,
|
|
artifact name, checksum, manifest schema, builder pin, image policy, and commit
|
|
binding. Its binary `DOWNLOAD` extension accepts HTTPS and at most one
|
|
allowlisted HTTPS redirect, does not forward the token across origins, bounds
|
|
the response, and refuses to overwrite an existing file. The installer checks
|
|
the exact audited helper fixture hash before applying its patch. The helper
|
|
and source code are not installed on the VPS by this PR.
|
|
|
|
## One-shot runtime binding proposed by PR #59
|
|
|
|
PR #59 adds a root-only, read-only status command and a fixed SSH dispatcher.
|
|
The dispatcher accepts only the literal status or deploy command in
|
|
`SSH_ORIGINAL_COMMAND`; it accepts no arguments and performs no shell
|
|
evaluation. Status fails closed on a stale root checkout, recovery journal,
|
|
incomplete Gitea run listing, failed source/workflow checks, invalid artifact
|
|
metadata/ZIP, or a release already applied. The candidate response contains
|
|
only a run ID, commit, and descriptor digest. The root receiver independently
|
|
repeats release verification and the existing backup/ACK/cutover guards.
|
|
|
|
The Windows client adds a one-shot `receive_external.py --once` mode. Its
|
|
configuration is fixed to `D:\Dev\akyldash` and the `akyldash_release` SSH
|
|
alias, and is disabled by default. It uses BatchMode, disables forwarding,
|
|
uses the existing host-key checking, bounds status output and time, then calls
|
|
the existing `run_release` path. Rollback remains a separate explicit
|
|
owner-run command. The example Task Scheduler XML is disabled, runs as the
|
|
interactive owner at least privilege, ignores overlapping instances, and
|
|
never wakes the computer. No task has been registered or enabled by this PR.
|
|
|
|
Before any activation, the owner must install the reviewed receiver and its
|
|
`archive.py` and `external_session.py` dependencies under a non-user-writable
|
|
`C:\Program Files\Akyldash` directory, set the config ACL so
|
|
only the owner, SYSTEM, and Administrators have full control, fill in the real
|
|
Python executable, owner SID, and local start time in the task template, and
|
|
confirm SSH host-key checking and the forced-command alias. Keep `enabled`
|
|
false and the task
|
|
disabled until the normal backup/restore and production readiness gates are
|
|
recorded. Do not bind a Gitea workflow or PR runner to this Windows host.
|
|
|
|
The root-side status endpoint requires `/opt/akyldash/current` to exactly
|
|
match current `main`; it does not update that checkout. An owner must advance
|
|
the root-controlled checkout through the approved installation process before
|
|
a release built from a newer commit can be considered ready. Gitea's filtered
|
|
workflow-run listing is bounded to ten entries; if Gitea reports more entries
|
|
or an inconsistent page, status returns unavailable rather than guessing.
|
|
|
|
## Automation boundary: deployment is not active
|
|
|
|
The automatic chain currently ends at release publication:
|
|
|
|
1. Successful `main` CI triggers image builds and publishes digest references
|
|
plus the release descriptor artifact.
|
|
2. `deploy-handoff.yaml` verifies the source run and may read artifact metadata.
|
|
Its job is explicitly status-only: **NOT DEPLOYED**. It does not download
|
|
the descriptor ZIP, call the Windows client, open SSH, or invoke the root
|
|
receiver. A green result means only that this status check completed.
|
|
3. The fixed receiver is physically started only by an explicitly enabled
|
|
owner-controlled Windows trigger or by the manual release CLI. The proposed
|
|
`--once` path queries root's verified status endpoint and receives the
|
|
fixed tuple; no repository workflow invokes it. The example scheduler and
|
|
config remain disabled, and no Windows trigger has been installed or
|
|
exercised.
|
|
|
|
Production CD is still not active: no Windows task or credential is installed,
|
|
and no VPS or live D: operation has been performed. This design avoids a
|
|
Windows Actions runner entirely; the owner-controlled local task is not exposed
|
|
to PR jobs. The SSH account/key must be restricted to the exact dispatcher
|
|
commands and verified host key. Do not use an unrestricted `authorized_keys`
|
|
entry or a persistent host-mode runner with D: and SSH access.
|
|
|
|
## External backup and cutover
|
|
|
|
The fixed root release receiver accepts only a bounded protocol request over
|
|
stdin. It does not accept a remote shell command, artifact path, or image
|
|
reference from the caller. It rechecks the release and current `main`, takes a
|
|
shared lock, captures running image IDs, and stops the stack. It streams the
|
|
cold archive directly to the owner's Windows client at
|
|
`D:\Dev\akyldash\.backups`; the VPS does not hold a full archive, including
|
|
temporarily. The Windows client requires a real NTFS destination with private
|
|
ACLs and a precise local Git exclude rule. It publishes only after hash,
|
|
archive, and manifest verification, and acknowledges the exact live session
|
|
nonce and backup identity.
|
|
|
|
Only after the acknowledgement does the host pull approved digest references,
|
|
atomically replace both image refs, and start Compose with `--no-build`. It
|
|
checks running image IDs, `/review`, and non-empty Russian and Kyrgyz search
|
|
canaries. A stale main, source mismatch, invalid archive, image mismatch, or
|
|
failed health/canary check stops cutover and attempts recovery using the
|
|
pre-change references. A recovery journal blocks another operation if
|
|
automatic recovery cannot be verified.
|
|
|
|
Rollback uses the root-pinned prior external archive and creates a fresh
|
|
external backup of current state before switching refs. It restores images
|
|
only, not data. Old local VPS backup paths and legacy release states without a
|
|
pinned external backup identity are rejected. See [backup and restore](BACKUP.md)
|
|
and [rollback](ROLLBACK.md).
|
|
|
|
The receiver records a durable pending recovery journal before stopping
|
|
services. A retry of the exact release already recorded in pinned state is
|
|
rejected before backup or downtime. Gitea source verification requires
|
|
`status=completed` and `conclusion=success`, and resolves current `main` from
|
|
the explicit production checkout. The Windows client checks the destination,
|
|
ACL, ignore rule, and full protocol archive capacity before opening SSH.
|
|
|
|
## Owner bootstrap still required
|
|
|
|
After review and merge, the owner must decide whether to install the helper
|
|
from a root-owned checkout and provision, without exposing values in logs:
|
|
|
|
- a read-only Gitea API token in `/etc/akyldash/gitea-api-token`, root-owned
|
|
mode `0600`;
|
|
- the exact artifact redirect origin allowlist in
|
|
`/etc/akyldash/gitea-download-origins`, if the Gitea artifact endpoint
|
|
redirects;
|
|
- approved Russian and Kyrgyz search canaries in
|
|
`/etc/akyldash/release-canaries.json`, root-owned mode `0600`;
|
|
- a root-only SSH path to `/usr/local/sbin/akyldash-release-deploy` and
|
|
`/usr/local/sbin/akyldash-release-rollback` using the existing owner key and
|
|
verified host key.
|
|
- a dedicated SSH alias `akyldash_release` backed by a key restricted to
|
|
`/usr/local/sbin/akyldash-release-dispatch`; its forced command must preserve
|
|
exact `SSH_ORIGINAL_COMMAND` matching and grant no shell, forwarding, PTY,
|
|
or arbitrary command access;
|
|
- a protected installation of the Windows client under
|
|
`C:\Program Files\Akyldash`, with the sample JSON and Task Scheduler XML
|
|
reviewed and kept disabled until the owner explicitly accepts unattended
|
|
polling.
|
|
|
|
The installer intentionally does not create credentials, SSH entries, canary
|
|
values, registry permissions, or a new privilege rule. Existing files with
|
|
unexpected owner, mode, or content cause installation to stop for owner
|
|
review. Do not run the installer or receiver from CI. The owner's first use
|
|
must be a separate-target restore check and a reviewed dry run; this PR does
|
|
not authorize a production cutover.
|
|
|
|
The Windows client uses the existing OpenSSH host-key checking. Its configured
|
|
alias must reach a root-controlled endpoint capable of invoking the fixed
|
|
receiver; no new key or sudo permission is requested. Windows ACL and NTFS
|
|
checks, SSH host configuration, artifact redirect origin, registry pull
|
|
access, and every production health gate remain unverified until the owner
|
|
checks them.
|