Add bounded Gitea CI build runner bootstrap for Synology
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
# Synology CI foundation
|
||||
|
||||
This additive `gitea-ci` component creates only the Gitea build runner. It does
|
||||
not activate automatic production apply, change Gitea itself, recreate Device
|
||||
Core, open a port or modify application databases. Track activation in
|
||||
DCPLATFORM-37; the canonical runner extension belongs to DCPLATFORM-21.
|
||||
|
||||
Initial policy: Device Core push to main automatically qualifies, then deploys
|
||||
once the separate production controller and recurring release contract have
|
||||
been accepted. Later repositories receive explicit registrations/policies.
|
||||
|
||||
## Reviewed contract
|
||||
|
||||
- Root: `/volume1/docker/nodedc-gitea-ci`.
|
||||
- Compose project: `nodedc-gitea-ci`; selected service: `build-runner`.
|
||||
- Three fixed data files: Compose, runner config, versioned descriptor.
|
||||
- Runner and Node images use official Linux amd64 manifest digests (not mutable
|
||||
tags), resolved from Docker Hub on 2026-09-29. The deploy runner pulls exactly
|
||||
these two digests. No repository-provided image names or commands.
|
||||
- Runner: 0.5 CPU, 512 MiB RAM, 128 PIDs, readonly root filesystem. Build jobs:
|
||||
one at a time, 1 CPU, 2 GiB RAM, 256 PIDs, no privileged mode, no host bind
|
||||
mounts, no host execution label and no Docker socket in job containers.
|
||||
- No published ports or host networking. Runner cache and metrics listeners
|
||||
are disabled. Communication uses outbound HTTPS to the existing Gitea.
|
||||
- Only the trusted runner daemon mounts the Docker socket. That daemon is
|
||||
privileged infrastructure even with dropped Linux capabilities: access to
|
||||
Docker is host authority. It is not passed to repository jobs.
|
||||
- The first worker is registered for `SILVER/NODEDC_DEVICE_CORE`; sharing with
|
||||
other repositories requires a reviewed enrollment/registry transition.
|
||||
|
||||
## Enrollment, separately from the artifact
|
||||
|
||||
Use the authenticated Gitea API to obtain the Device Core repository runner
|
||||
registration token. Do not copy a personal Git token into the runner.
|
||||
Prepare `/volume1/docker/nodedc-deploy/runtime/gitea-ci/enrollment.pending.json`
|
||||
as a private regular single-link file (mode 0600), containing only the exact
|
||||
repository identity and its registration token. Never put this file in Git,
|
||||
inbox, artifact payload, logs, Ops text or chat. The canonical runner imports
|
||||
the token into a root-owned runtime file and mounts it readonly. Gitea creates
|
||||
the persistent `/data/.runner` identity on first start. Its content is secret.
|
||||
|
||||
The bootstrap accepts no existing installed CI descriptor or CI container.
|
||||
Preflight also checks at least 8 GiB free disk and 3 GiB currently available
|
||||
memory. If that capacity is unavailable, review smaller fixed limits or another
|
||||
worker placement; do not bypass the preflight.
|
||||
|
||||
## Build and install
|
||||
|
||||
From a clean Platform commit:
|
||||
|
||||
```sh
|
||||
python3 -m unittest discover -s infra/gitea-ci -p 'test_*.py'
|
||||
python3 infra/gitea-ci/build_artifact.py --patch-id gitea-ci-bootstrap-v1-<unique-id> --source-commit <full-sha> --output-dir <output-dir>
|
||||
```
|
||||
|
||||
The first use requires promotion of the reviewed root runner through the
|
||||
separate atomic administrative gate and fresh `verify-install`. Stage the
|
||||
immutable `.tgz` in the canonical inbox and inspect its lifecycle. Obtain a
|
||||
fresh `nodedc-deploy plan`, review exact scope, then apply that artifact once.
|
||||
|
||||
`apply` snapshots the source partition and identities of all preexisting
|
||||
containers. Acceptance checks the pinned image, Compose identity, mounts,
|
||||
resource limits, privileges and absence of port publications. It requires
|
||||
registration plus ten seconds of stable daemon operation and unchanged
|
||||
preexisting container identities. All secrets and application data are outside
|
||||
the artifact/backup source partition.
|
||||
|
||||
If startup or acceptance fails, rollback removes only `build-runner` and
|
||||
restores only the three source paths. Runner registration and enrollment are
|
||||
preserved for diagnosis. A failed attempt may leave an offline registration in
|
||||
Gitea; do not create another token or delete persistent identity blindly.
|
||||
The global failed-artifact replay rule remains in force.
|
||||
|
||||
After `deploy-ok`, verify online registration and a real qualification job via
|
||||
Gitea API/UI. This is separate functional acceptance; do not ask an operator
|
||||
to re-prove Docker/runtime checks with NAS shell commands. Do not describe the
|
||||
runner bootstrap or a green build as a completed automatic production deploy.
|
||||
|
||||
## Validation baseline
|
||||
|
||||
Installed predecessor confirmed by the operator on 2026-09-29:
|
||||
`f21936f131365bd3993e2d746e332538d628ba50ef62c1cce833161171ffde47`,
|
||||
Python 3.8.15, `verify-install-ok`. This matches Platform commit
|
||||
`11b73e64681f83aa2ebfd89ef266d3be2869f7e1`. The older SMB runner copy is not the
|
||||
installed authority. Historical Gitea recovery guards remain unchanged.
|
||||
|
||||
Tests cover deterministic packaging, exact runtime/payload boundaries, secret
|
||||
file handling, bootstrap reuse rejection, preserved container identity, real
|
||||
synthetic-host apply receipts, and failed-health source rollback with runtime
|
||||
registration retained. Existing Platform/Device/Gitea regression suites are
|
||||
also required before promotion.
|
||||
|
||||
References: [official runner configuration](https://docs.gitea.com/runner/configuration/),
|
||||
[Docker installation](https://docs.gitea.com/runner/installation/docker/).
|
||||
Reference in New Issue
Block a user