ci: publish image to the own registry on release tag
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m16s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 10s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 41s
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m16s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 10s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 41s
Build Dockerfile on every v* tag push (created by release-please when the release PR merges) and push registry.noelsabia.dev/cv_website/nuxt as the version, sha-<12> and latest. Main pushes do not build: the registry holds releases, not commits. The job runs in node:22-bookworm and needs only the Docker client, so the act_runner must expose its host socket (container.docker_host: automount); a preflight step fails with that cause when it does not.
This commit is contained in:
1 parent
db04d441c9
commit
c3cf1dfc47
5 files changed
+239
No files matched your search
@@ -0,0 +1,117 @@
|
||||
name: Publish image
|
||||
|
||||
# Fires on the version tag release-please creates when the release PR is
|
||||
# merged (vX.Y.Z, plain tags - see OKF_Nuxt/decisions/release-engineering.md).
|
||||
# A push to main does NOT build: an image tag always maps to a released
|
||||
# version, so what runs in the cluster is traceable to a release, not to an
|
||||
# arbitrary commit.
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
# The runner has capacity 1, so releases already serialize. This keeps a
|
||||
# manual re-run from racing a fresh release on the same tags.
|
||||
concurrency:
|
||||
group: publish-image
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
# Registry host + repository path. The path segment is the Gitea
|
||||
# organisation, so k3s pulls registry.noelsabia.dev/cv_website/nuxt:<tag>.
|
||||
IMAGE: registry.noelsabia.dev/cv_website/nuxt
|
||||
APP_DIR: .
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Build and push image
|
||||
runs-on: ubuntu-latest
|
||||
# Same base image as the other jobs. The build runs on the runner's
|
||||
# Docker daemon (not in a nested daemon), so this container only needs
|
||||
# the CLI - see OKF_Nuxt/decisions/registry-publishing.md.
|
||||
container: node:22-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Docker CLI
|
||||
# Debian's docker.io, not a curl-piped binary from GitHub: apt is a
|
||||
# signed channel, and bookworm ships an arm64 build. Only the client
|
||||
# is needed; the daemon lives on the host.
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends docker.io
|
||||
docker --version
|
||||
|
||||
- name: Check daemon access
|
||||
# Fail here, with the cause, instead of halfway through a build.
|
||||
# An unreachable daemon means the runner was started without the
|
||||
# host socket mounted: set `docker_host: automount` in the
|
||||
# act_runner config and restart the service.
|
||||
run: |
|
||||
echo "DOCKER_HOST=${DOCKER_HOST:-<unset - the default socket path>}"
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
echo "::error::no Docker daemon reachable from this job - the act_runner needs the host Docker socket (docker_host: automount)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Resolve version and tags
|
||||
id: version
|
||||
run: |
|
||||
# GITHUB_REF_NAME is the tag on a tag push. The git fallback keeps
|
||||
# this working if a runner version does not set it.
|
||||
version="${GITHUB_REF_NAME:-$(git describe --tags --exact-match HEAD)}"
|
||||
case "$version" in
|
||||
v[0-9]*) ;;
|
||||
*) echo "::error::expected a vX.Y.Z tag, got '${version}'"; exit 1 ;;
|
||||
esac
|
||||
# Short SHA tag alongside the version: OKF_CV_Website/architecture/
|
||||
# delivery.md asks for SHA-tagged images so every deploy is
|
||||
# traceable to a commit even after a tag is moved.
|
||||
sha="$(git rev-parse --short=12 HEAD)"
|
||||
{
|
||||
echo "version=${version}"
|
||||
echo "sha=${sha}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
echo "Building ${version} from ${sha}"
|
||||
|
||||
- name: Log in to the registry
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
# Missing secrets must fail loudly: an anonymous `docker push`
|
||||
# would answer 401 with a message most people misread as a
|
||||
# missing repository.
|
||||
[ -n "$REGISTRY_USERNAME" ] || { echo "::error::secret REGISTRY_USERNAME is empty"; exit 1; }
|
||||
[ -n "$REGISTRY_PASSWORD" ] || { echo "::error::secret REGISTRY_PASSWORD is empty"; exit 1; }
|
||||
printf '%s' "$REGISTRY_PASSWORD" \
|
||||
| docker login registry.noelsabia.dev -u "$REGISTRY_USERNAME" --password-stdin
|
||||
|
||||
- name: Build image
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
SHA: ${{ steps.version.outputs.sha }}
|
||||
run: |
|
||||
# --platform is explicit so a build on the wrong architecture fails
|
||||
# instead of silently producing an amd64 image the arm64 node
|
||||
# cannot run. Native here, no QEMU involved.
|
||||
docker build \
|
||||
--platform linux/arm64 \
|
||||
--label "org.opencontainers.image.version=${VERSION}" \
|
||||
--label "org.opencontainers.image.revision=${SHA}" \
|
||||
-t "${IMAGE}:${VERSION}" \
|
||||
-t "${IMAGE}:sha-${SHA}" \
|
||||
-t "${IMAGE}:latest" \
|
||||
"${APP_DIR}"
|
||||
|
||||
- name: Push image
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
SHA: ${{ steps.version.outputs.sha }}
|
||||
run: |
|
||||
# Explicit per tag, not `--all-tags`: --all-tags would also push
|
||||
# stale local tags left on the shared daemon by earlier runs.
|
||||
docker push "${IMAGE}:${VERSION}"
|
||||
docker push "${IMAGE}:sha-${SHA}"
|
||||
docker push "${IMAGE}:latest"
|
||||
echo "Pushed ${IMAGE}:${VERSION}, :sha-${SHA}, :latest"
|
||||
@@ -5,6 +5,7 @@
|
||||
* [Vulnerability audit policy](vulnerability-audit-policy.md) - Blocking audit, reviewed ignore-list for unfixable advisories, and the pnpm-11 settings home.
|
||||
* [Release engineering](release-engineering.md) - release-please in manifest mode, conventional commits as input, message format enforced at commit time.
|
||||
* [Snyk paused and secrets policy](snyk-paused-and-secrets-policy.md) - Why the job is skipped rather than deleted, and the token scopes every workflow secret needs.
|
||||
* [Publishing images to the own registry](registry-publishing.md) - A release tag builds and pushes to registry.noelsabia.dev; main pushes do not build.
|
||||
* [Dev container shape](dev-container-shape.md) - The source is bind-mounted into a container that already holds the dependencies, and the dev server runs as the image's `node` user.
|
||||
* [Build layer order](build-layer-order.md) - Why the manifests are copied before the source, and what invalidates what.
|
||||
* [Build context filter](build-context-filter.md) - What `.dockerignore` may exclude, and the one thing it must never exclude.
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
---
|
||||
type: Decision
|
||||
title: Publishing images to the own registry
|
||||
description: A release tag builds the production image and pushes it to registry.noelsabia.dev, because that is the only way Kubernetes can pull it.
|
||||
tags: [decision, ci, docker, registry, gitea-actions]
|
||||
status: draft
|
||||
generated: { by: opencode-go/deepseek-v4.1-flash, at: 2026-10-24T00:00:00Z }
|
||||
verified: { by: human:noel, at: not yet }
|
||||
sources:
|
||||
- id: workflow
|
||||
resource: .gitea/workflows/publish-image.yml
|
||||
title: Publish image workflow
|
||||
- id: dockerfile
|
||||
resource: Dockerfile
|
||||
title: Production Dockerfile
|
||||
- id: k8s
|
||||
resource: ../OKF_CV_Website/architecture/delivery.md
|
||||
title: Sibling bundle - image tags and registry pull
|
||||
---
|
||||
|
||||
# Decision
|
||||
|
||||
`.gitea/workflows/publish-image.yml` builds `Dockerfile` and pushes the
|
||||
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
|
||||
```
|
||||
|
||||
**Trigger is the release tag, not the main push.** release-please creates
|
||||
`vX.Y.Z` when the release PR is merged ([release
|
||||
engineering](release-engineering.md)); that tag push is the build. A main
|
||||
push would otherwise publish commits that no release describes, and
|
||||
`latest` would move on work in progress.
|
||||
|
||||
# Why not build on every main push
|
||||
|
||||
* The registry is the deployment channel. Every image in it should answer
|
||||
"which release is this", and a tagged commit does.
|
||||
* The runner has capacity 1 and shares 2 vCPU / 4 GB with Gitea and k3s
|
||||
(`OKF_CV_Website/architecture/server-budget.md`). A Nuxt image build can
|
||||
take over 1 GB; running it more often than a release buys nothing.
|
||||
* The PR checks already gate the code that becomes a release. A tag build
|
||||
is not the first time the tree is built - a failing build here is a
|
||||
packaging failure, not a surprise.
|
||||
|
||||
# Why docker-outside-of-docker
|
||||
|
||||
The job runs in `node:22-bookworm`, like every other job in this
|
||||
repository, and only needs the Docker client: `docker build` sends the
|
||||
build context over the socket, so the daemon never reads the container's
|
||||
filesystem. That requires the act_runner to mount its host socket:
|
||||
|
||||
```yaml
|
||||
# act_runner config.yaml
|
||||
container:
|
||||
docker_host: automount
|
||||
```
|
||||
|
||||
Without it the `Check daemon access` step fails first with a named cause
|
||||
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.
|
||||
|
||||
# Why `--platform linux/arm64`
|
||||
|
||||
The runner and the node are the same arm64 machine, so the build is native
|
||||
(no QEMU, no crossed dependencies). Stating the platform makes a build on
|
||||
another architecture fail instead of publishing an image the node cannot
|
||||
run.
|
||||
|
||||
# Secrets
|
||||
|
||||
| Gitea secret | Use |
|
||||
|---|---|
|
||||
| `REGISTRY_USERNAME` | basic-auth user for `docker login registry.noelsabia.dev` |
|
||||
| `REGISTRY_PASSWORD` | basic-auth password (or token) for the same login |
|
||||
|
||||
Both are repo secrets. The login uses `--password-stdin` so the value never
|
||||
appears in the process list or the log.
|
||||
|
||||
# Costs and consequences
|
||||
|
||||
* **Registry storage grows** by one image per release in three tags. The
|
||||
three tags share layers, so the extra cost is mostly the tag, not the
|
||||
bytes.
|
||||
* **Images accumulate on the runner's daemon** (`sha-`, version and
|
||||
`latest` tags). Pruning is not part of this change; add a
|
||||
`docker image prune` policy when the disk usage actually matters.
|
||||
* **`latest` is a convenience, not a pin.** Manifests should reference the
|
||||
version or SHA tag so a release rollback is a manifest edit.
|
||||
* **k3s needs pull credentials**: an `imagePullSecret` in the namespace for
|
||||
the same basic-auth pair, or `/etc/rancher/k3s/registries.yaml` if the
|
||||
registry is ever plain HTTP. Not part of this workflow.
|
||||
|
||||
# Not verified
|
||||
|
||||
* That the runner has the host socket mounted (`docker_host: automount`) -
|
||||
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 `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.
|
||||
|
||||
# Revisit when
|
||||
|
||||
* A second image (the Go gateway or chapter service) needs publishing -
|
||||
then the workflow grows a matrix instead of being copied.
|
||||
* Deploys should follow automatically: the release workflow gains a
|
||||
`kubectl set image` step, or manifests start referencing the SHA tag.
|
||||
* Multi-arch becomes necessary (a laptop or a CI host of the other
|
||||
architecture pulls the image).
|
||||
@@ -22,6 +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.
|
||||
|
||||
## Docker and development environment
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# Update Log
|
||||
|
||||
## 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).
|
||||
|
||||
## 2026-10-20 (cheaper review model, cached installs, merged checks)
|
||||
* **Update**: [pr-checker.yml](../.gitea/workflows/pr-checker.yml) - the review model is now `opencode-go/claude-haiku-5-5#medium`: cheap per token and, unlike `deepseek-v4.1-flash`, it has a real `#medium` effort level (flash exposes only low/high/max). ESLint and typecheck are merged into one `checks` job with a single `pnpm install`, and the pnpm store plus the opencode binary are restored with `actions/cache@v4.1.0` (v1 cache API, so it also works on a v1-only runner). Cache keys are built from `sha256sum pnpm-lock.yaml`, the pnpm store layout (`v11`) and the opencode version in shell steps, because `hashFiles()` evaluates empty in this act runner. See [AI review setup](decisions/ai-review-setup.md) and [PR pipeline layering](decisions/pr-pipeline-layering.md).
|
||||
|
||||
|
||||
Reference in new issue
Block a user