fix(ci): harden the release publish workflow after the PR review
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m5s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 8s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 48s

Applied the findings that held up against the code:
- strict vMAJOR.MINOR.PATCH guard; v[0-9]* accepted v1, v1-foo and
  prereleases, all valid registry tags
- latest now follows the newest release, so replaying an older tag cannot
  drag it backwards; skipped with a warning if the tag list is unavailable
- smoke test starts the built image and requires 2xx on / before pushing
- timeout-minutes: 20 on the job, so a hung build cannot hold the
  capacity-1 runner indefinitely
- the decision doc records the socket's blast radius: root-equivalent,
  runner-wide, only on a label PR jobs cannot use

Rejected with evidence: the .dockerignore leak (.env*, *.pem, .git are
excluded) and the Docker client/daemon API mismatch (20.10.24 client
against a 29.9.2 daemon builds over the socket).
This commit is contained in:
Noel Sabia committed 2026-10-24 19:15:55 +02:00
1 parent f3d3e196d0
commit 435be63ae0
4 files changed
+132 -25

No files matched your search

+37 -1
View File
@@ -26,7 +26,7 @@ result to the own registry:
```
registry.noelsabia.dev/cv_website/nuxt:v1.2.3
registry.noelsabia.dev/cv_website/nuxt:sha-<12-char-sha>
registry.noelsabia.dev/cv_website/nuxt:latest
registry.noelsabia.dev/cv_website/nuxt:latest # newest release only
```
**Trigger is the release tag, not the main push.** release-please creates
@@ -64,6 +64,27 @@ instead of a mid-build error. The alternative - a privileged `docker:dind`
sidecar - needs privileged mode and a second daemon per release; not worth
it on this server.
## Trust boundary (the cost of the socket)
A mounted Docker socket is **root-equivalent on the host**: any job that
has it can run `docker run -v /:/host` and read or write anything, which on
this machine means Gitea's data, k3s, and the CV itself. `docker_host` is a
**runner-wide** setting, so enabling it gives the socket to every job on
that runner, including PR jobs whose code comes from a branch.
Therefore the rule: **the socket only ever goes on a runner label that
PR-triggered jobs do not use.** Two acceptable layouts:
* a second act_runner registration with `docker_host: automount` and a
distinct label (e.g. `publish`), used only by this workflow; or
* one runner, but this workflow moved to the dedicated label and
`pr-checker.yml` left on a label without the socket.
Not acceptable: adding `automount` to the single shared runner while
`pr-checker.yml` runs on it. If that is the only option, treat it as an
accepted risk and record it here - the trade is "PR code can become root on
the host" against "images can be built at all".
# Why `--platform linux/arm64`
The runner and the node are the same arm64 machine, so the build is native
@@ -81,6 +102,15 @@ run.
Both are repo secrets. The login uses `--password-stdin` so the value never
appears in the process list or the log.
# Guards in the workflow
| Guard | Why |
|---|---|
| Strict `^vMAJOR.MINOR.PATCH$` check | A `v[0-9]*` prefix match accepts `v1`, `v1-anything` and `v1.2.3-rc1`, all of which are valid registry tags and would publish silently |
| `latest` only when the built tag is the highest `vX.Y.Z` in the repository | Gitea can replay any run. Without the comparison, re-running `v1.2.0` after `v1.3.0` drags `latest` backwards. A re-run of the newest tag still moves it - that release had not produced an image yet. If the tag list cannot be fetched, `latest` is skipped with a warning rather than guessed |
| Smoke test before any push | The image is started and must answer 2xx on `/` from inside the container. Build success only proves the bundle compiled. Port publishing is not usable here: the daemon binds on the host, not in the job container |
| `timeout-minutes: 20` | A hung build would hold the capacity-1 runner and every job queued behind it |
# Costs and consequences
* **Registry storage grows** by one image per release in three tags. The
@@ -101,10 +131,16 @@ appears in the process list or the log.
the workflow's first step answers this on the first release.
* That the arm64 build succeeds: `Dockerfile` has been built on x86_64
only ([production image](production-image.md)).
* That the smoke test passes on arm64. The same script was run against an
x86_64 build of the merged tree and answered 2xx; the arm64 run is the
first release.
* That `registry.noelsabia.dev` is reachable over HTTPS from the runner.
A plain-HTTP endpoint fails `docker login` with `server gave HTTP
response to HTTPS client` and needs `insecure-registries` on the daemon
plus `registries.yaml` on k3s.
* Whether Gitea runs a `pull_request` workflow from a fork without
maintainer approval on this instance. That answer decides how severe the
socket risk above really is.
# Revisit when