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
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:
1 parent
f3d3e196d0
commit
435be63ae0
4 files changed
+132
-25
No files matched your search
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ config files — the configs say what, these documents say why.
|
||||
* [Vulnerability audit policy](decisions/vulnerability-audit-policy.md) - Blocking audit; reviewed ignore-list for unfixable advisories in pnpm-workspace.yaml.
|
||||
* [Release engineering](decisions/release-engineering.md) - release-please in manifest mode; conventional commits enforced at commit time.
|
||||
* [Snyk paused and secrets policy](decisions/snyk-paused-and-secrets-policy.md) - Quota-paused job kept in place; `write:issue` scope required on every workflow token.
|
||||
* [Publishing images to the own registry](decisions/registry-publishing.md) - A release tag builds the image and pushes it to registry.noelsabia.dev, with `docker_host: automount` on the runner.
|
||||
* [Publishing images to the own registry](decisions/registry-publishing.md) - A release tag builds the image and pushes it to registry.noelsabia.dev; the runner socket it needs is root-equivalent and belongs on a separate label.
|
||||
|
||||
## Docker and development environment
|
||||
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
## 2026-10-24 (release publishes an image)
|
||||
|
||||
* **Creation**: [publish-image.yml](../.gitea/workflows/publish-image.yml) - a `v*` tag push builds `Dockerfile` on the arm64 runner and pushes `registry.noelsabia.dev/cv_website/nuxt` as the version, `sha-<12>`, and `latest`. Main pushes deliberately do not build: the registry holds releases, not commits. The job uses the runner's own Docker daemon (client only in the `node:22-bookworm` container), so the act_runner needs `container.docker_host: automount`; the first step fails with that cause if it is missing. Repo secrets: `REGISTRY_USERNAME`, `REGISTRY_PASSWORD`. See [Publishing images to the own registry](decisions/registry-publishing.md).
|
||||
* **Creation**: [publish-image.yml](../.gitea/workflows/publish-image.yml) - a `vX.Y.Z` tag push builds `Dockerfile` on the arm64 runner and pushes `registry.noelsabia.dev/cv_website/nuxt` as the version and `sha-<12>`, plus `latest` when that tag is the newest release. Main pushes deliberately do not build: the registry holds releases, not commits. The job uses the runner's own Docker daemon (client only in the `node:22-bookworm` container), so the act_runner needs `container.docker_host: automount`; the first step fails with that cause if it is missing. That socket is root-equivalent, so it may only sit on a label PR jobs cannot use - recorded under the trust boundary in [Publishing images to the own registry](decisions/registry-publishing.md). Repo secrets: `REGISTRY_USERNAME`, `REGISTRY_PASSWORD`.
|
||||
* **Review follow-up** (PR #19, 1 BLOCKER + 4 WARN + 2 NIT): applied the strict `vMAJOR.MINOR.PATCH` check, the newest-release rule for `latest`, a smoke test that starts the image and requires 2xx on `/`, and `timeout-minutes: 20`. 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 built successfully over the socket).
|
||||
|
||||
## 2026-10-23 (PR #16 review checked, three findings applied)
|
||||
* **Update**: [pr-checker.yml](../.gitea/workflows/pr-checker.yml) - the review prompt now states that `pnpm-lock.yaml` is excluded from `.pr-review-diff.patch` on purpose. The reviewer read the exclusion as an uncommitted lockfile and raised a false BLOCKER; the lockfile is in the PR and matches `package.json`.
|
||||
|
||||
Reference in new issue
Block a user