From 3139e8e2397bc4398ba2506bb9edae228699ff09 Mon Sep 17 00:00:00 2001 From: Adam French Date: Thu, 26 Nov 2026 16:00:13 +0000 Subject: [PATCH] CI: run tests and Renovate on the build VM The test job and Renovate move to stpbuild's runner (label `build`), a new Proxmox VM; deploy and maintenance stay on stpvm (`self-hosted`). test fetches over HTTP with the job's own GITEA_TOKEN. DEPLOYMENT.md gains a "Build VM" section, and CLAUDE.md says where each job runs. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/deploy.yaml | 19 ++++++++++++++----- .gitea/workflows/renovate.yaml | 5 +++-- CLAUDE.md | 2 +- DEPLOYMENT.md | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index c666495..ab8b33c 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -1,4 +1,6 @@ -# `test` runs on every push; `deploy` runs for main only after it passes. +# `test` runs on every push, on the build VM (stpbuild, label `build`); +# `deploy` runs for main only after it passes, on stpvm (`self-hosted`), +# since it recreates the stack there. # The runner is in host mode with only git and docker on the host, so Go and # Python run in containers pinned to the same images as their Dockerfiles # (bump together), and checkout is plain git rather than actions/checkout. @@ -11,13 +13,15 @@ on: jobs: test: - runs-on: self-hosted + runs-on: build env: # Via env so a branch name is never parsed as shell. SHA: ${{ github.sha }} REF: ${{ github.ref }} - REMOTE: ssh://git@git.adam-french.co.uk:2222/adamf/stpweb.git - GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" + # Over HTTP with the job's own token (read access to this repo while + # the job runs), so the runner needs no SSH key or Gitea user. + REMOTE: http://git.adam-french.co.uk:3000/adamf/stpweb.git + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} # Kept between runs so fetches are incremental. CACHE: /home/adamf/.cache/stpweb-ci/repo.git SRC: /home/adamf/.cache/stpweb-ci/src-${{ github.sha }} @@ -30,7 +34,12 @@ jobs: [ -d "$CACHE" ] || git init --quiet --bare "$CACHE" # $SHA, not FETCH_HEAD: test this run's commit even if the # branch has moved on. - git --git-dir="$CACHE" fetch --quiet --no-tags "$REMOTE" "$REF" + # The job's token as a Basic auth header, passed via env rather + # than -c so it never shows in the process list. + auth=$(printf 'x-access-token:%s' "$GITEA_TOKEN" | base64 -w0) + GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader \ + GIT_CONFIG_VALUE_0="Authorization: Basic $auth" \ + git --git-dir="$CACHE" fetch --quiet --no-tags "$REMOTE" "$REF" rm -rf "$SRC" mkdir -p "$SRC" git --git-dir="$CACHE" archive --format=tar "$SHA" | tar -x -C "$SRC" diff --git a/.gitea/workflows/renovate.yaml b/.gitea/workflows/renovate.yaml index da3a859..37d2570 100644 --- a/.gitea/workflows/renovate.yaml +++ b/.gitea/workflows/renovate.yaml @@ -1,4 +1,5 @@ -# Weekly Renovate run (config in /renovate.json5). --network host uses the +# Weekly Renovate run (config in /renovate.json5), on the build VM (stpbuild, +# label `build`). --network host uses the # host's /etc/hosts pin to reach Gitea on the LAN, and RENOVATE_GIT_URL=endpoint # stops it cloning via the public ROOT_URL. Secrets are passed as bare `-e NAME` # so they never appear in the process list. Gitea refuses secret names starting @@ -13,7 +14,7 @@ on: jobs: renovate: - runs-on: self-hosted + runs-on: build steps: - name: Run Renovate shell: bash diff --git a/CLAUDE.md b/CLAUDE.md index 7f37f8e..62ad2f9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -63,7 +63,7 @@ Dockerized multi-service personal website self-hosted on `stpvm` (an x86-64 Ubun **Job tracker and notes editor** (on stppriv): the job tracker (`adamf/job-tracker`) and the SilverBullet editor run on their own LXC, from the `adamf/stppriv` repo, at `priv.`. stppriv's Caddy gates them with this site's admin session (the cookie is set for the parent domain), asking `/api/auth/validate-admin` over the LAN; requests from `STPPRIV_LAN_IP` to that path skip the api rate limit. Caddy here 301s `/sb/`, `/jobs/` and the old `/cv/jobs`, `/cv/leads` and userscript URLs there. stppriv is the notes vault's only writer; `silverbullet-git` here runs with `SYNC_MODE=pull` and feeds `/notes/`. -**Gitea** (own repo, `adamf/stpgit`): git, Actions and the image registry (`/adamf/...`) run in their own Proxmox LXC since 2026-11-24, from the `adamf/stpgit` repo (this repo's `gitea/` directory until then) with their own Postgres (`gitea-db`) and `.env`, deployed by hand there and never by CI. Everything on stpvm reaches it as `GITEA_HOST` (`git.`, :3000 HTTP and :2222 SSH), pinned to the LXC's LAN IP (`GITEA_UPSTREAM`) by `extra_hosts` in containers and `/etc/hosts` on the host; public DNS for that name is Cloudflare, which carries only HTTPS. There is no Gitea container or forwarder in this stack since 2026-11-24. The act_runner stays on stpvm. Runbook: that repo's README, summarised in "Gitea LXC" in `DEPLOYMENT.md` §7. +**Gitea** (own repo, `adamf/stpgit`): git, Actions and the image registry (`/adamf/...`) run in their own Proxmox LXC since 2026-11-24, from the `adamf/stpgit` repo (this repo's `gitea/` directory until then) with their own Postgres (`gitea-db`) and `.env`, deployed by hand there and never by CI. Everything on stpvm reaches it as `GITEA_HOST` (`git.`, :3000 HTTP and :2222 SSH), pinned to the LXC's LAN IP (`GITEA_UPSTREAM`) by `extra_hosts` in containers and `/etc/hosts` on the host; public DNS for that name is Cloudflare, which carries only HTTPS. There is no Gitea container or forwarder in this stack since 2026-11-24. stpvm keeps an act_runner (label `self-hosted`) for the jobs that touch the stack (deploys, maintenance); tests, image builds and Renovate run on the build VM `stpbuild` (Proxmox VM 123, 192.168.178.240, label `build`) since 2026-11-26, which fetches over HTTP with each job's own `GITEA_TOKEN`. See "Build VM" in `DEPLOYMENT.md` §7. Runbook: that repo's README, summarised in "Gitea LXC" in `DEPLOYMENT.md` §7. **Uploads / Garage** (Garage itself on stpcore): every stored file goes through one path. Frontend: `vue/src/uploads.js` (`uploadFile(file)` → URL, plus `ACCEPT` for pickers, `kindOf`, `isUploadUrl`, `tagFor`). Backend: `POST /api/uploads` (`handlers/handle_upload.go`), a thin wrapper over `services.Uploads.Save` (`services/uploads.go`), which owns the type table (`UploadTypes`), the 10MB limit, random naming and storage. A new feature that takes a file calls those, never its own endpoint. `GET /api/uploads` (admin only, `Uploads.List`, `listUploads()`) lists what is stored, bucket and disk merged, for `components/util/UploadPicker.vue`, the "choose an existing upload" modal used by the canvas's Background panel, Box editor and admin bar. Public files go to a bucket in Garage (the `uploads` volume when `S3_ENDPOINT` is unset, or when Garage refuses a write). Garage and `garage-webui` are not in this stack: they run on the `stpcore` LXC, from the `adamf/stpcore` repo (the shared core other stacks depend on; its README is the runbook, including `garage/bootstrap.sh`), and the name `garage` is pinned to its LAN IP (`GARAGE_UPSTREAM`) by `extra_hosts` in `caddy`, `backend` and `usaco`. Caddy serves `/uploads/` from Garage's anonymous website endpoint (`garage:3902`) first and the volume second, so the bucket is the source of truth and a Garage or stpcore outage only affects bucket-only files. Private attachments (`/uploads/private/`) always stay on disk. `/garage/` (admin-gated) proxies to stpcore's Caddy on `garage:3909`, adding `X-Core-Token` (`GARAGE_WEBUI_TOKEN`), which that Caddy requires before it forwards to garage-webui. A new consumer of the store gets its own key and bucket on stpcore and the same `extra_hosts` pin. "Garage" in `DEPLOYMENT.md` §7 covers this side. diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index fcdd1da..d39177b 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -723,6 +723,22 @@ nothing, so pull and `up -d` there afterwards. `docker compose -f docker-compose.yml -f .deprecated/gitea/docker-compose.gitea.yml up -d gitea`. `.deprecated/README.md` has the details. +**Build VM (stpbuild).** Since 2026-11-26 CI is split over two runners. +stpvm's (`self-hosted`, in `gitea-runner/` here) keeps only the jobs that +touch this stack: `deploy` in this repo's deploy.yaml and in usaco's and +activity-tracker's ci.yaml, and maintenance.yaml. Everything that only needs +git and docker (tests, image builds and pushes, Renovate) runs on +`stpbuild-runner` (label `build`, instance-wide, capacity 2), on the Proxmox +VM `stpbuild` (VMID 123, `192.168.178.240`, Ubuntu 24.04, 4 cores, 2 GB + 4 GB +swapfile), from `~/deploy/stpbuild/gitea-runner` with an `@reboot` crontab +line. Its `/etc/hosts` pins `git.` to stpgit's LAN IP and the apex to +stpvm's (registry pushes go to this Caddy over the LAN, not Cloudflare). It +has no SSH key: build jobs fetch from `http://git.:3000/` with the +job's own `secrets.GITEA_TOKEN`, so a new repo needs no Gitea setup, only +`runs-on: build`. A `publish` job reuses its `test` job's git cache, so both +must stay on `build`. stpweb's own images are still built here by +`up --build`; moving them is the next step. + **Set up the CI runner on a fresh host:** ```