diff --git a/.env.dev b/.env.dev index b7ccdc9..70ef72e 100644 --- a/.env.dev +++ b/.env.dev @@ -42,12 +42,6 @@ GITEA_HOST=git.localhost GITEA_PORT=3000 GITEA_UPSTREAM=192.0.2.1 -# --- Gitea Actions runner ---------------------------------------------------- -# The runner is not part of the compose stack; nothing in dev reads these. -GITEA_RUNNER_HOST= -GITEA_RUNNER_NAME=dev-runner -GITEA_RUNNER_REGISTRATION_TOKEN=dev-dummy-runner-token - # --- SilverBullet (notes) --------------------------------------------------- SILVERBULLET_PORT=3000 SILVERBULLET_PUBLIC_HOST=silverbullet-public diff --git a/.env.example b/.env.example index 009b139..8b6c284 100644 --- a/.env.example +++ b/.env.example @@ -60,15 +60,6 @@ GITEA_HOST=git.adam-french.co.uk GITEA_PORT=3000 GITEA_UPSTREAM= -# --- Gitea Actions runner ---------------------------------------------------- -# The runner is NOT a container; it runs on stpvm via gitea-runner/run.sh. -# The registration token is SINGLE-USE: it is exchanged for a permanent -# identity in gitea-runner/.runner on first registration, after which this -# value is ignored. Mint it in Site Administration -> Actions -> Runners. -GITEA_RUNNER_HOST= -GITEA_RUNNER_NAME=pi-runner -GITEA_RUNNER_REGISTRATION_TOKEN= - # --- SilverBullet (notes) --------------------------------------------------- # The public read-only notes site at /notes/. The editor, and the vault's only # writer, is stppriv (priv.DOMAIN/sb/); silverbullet-git here only pulls. diff --git a/.gitea/workflows/renovate.yaml b/.gitea/workflows/renovate.yaml index 37d2570..718caec 100644 --- a/.gitea/workflows/renovate.yaml +++ b/.gitea/workflows/renovate.yaml @@ -31,7 +31,7 @@ jobs: -e RENOVATE_PLATFORM=gitea \ -e RENOVATE_ENDPOINT=http://git.adam-french.co.uk:3000/api/v1 \ -e RENOVATE_GIT_URL=endpoint \ - -e RENOVATE_REPOSITORIES=adamf/stpweb,adamf/stpgit,adamf/stppriv,adamf/stpcore \ + -e RENOVATE_REPOSITORIES=adamf/stpweb,adamf/stpgit,adamf/stppriv,adamf/stpcore,adamf/stprunner \ -e RENOVATE_TOKEN \ -e GITHUB_COM_TOKEN \ -e LOG_LEVEL=info \ diff --git a/.gitignore b/.gitignore index e667356..8e5c020 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,14 @@ usaco-data/ .deprecated/gitea/config/ .deprecated/gitea/dev-leftovers/ -# Gitea runner +# The old runner directory: gone from git, but still on stpvm holding the +# previous .runner credentials (runners are installed from adamf/stprunner) gitea-runner/.runner gitea-runner/act_runner +gitea-runner/gitea-runner +gitea-runner/.runner.lock +# Old registrations: credentials, like .runner +gitea-runner/.runner.bak* gitea-runner/nohup.out # Python bytecode diff --git a/CLAUDE.md b/CLAUDE.md index 3417bb5..64ef615 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. 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. +**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 a gitea-runner (registered as `stpvm`, 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, runner `stpbuild-runner`, label `build`) since 2026-11-26, which fetches over HTTP with each job's own `GITEA_TOKEN`. Both runners are installed from the `adamf/stprunner` repo (systemd, `hosts/.env` per VM). 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 d39177b..6376ad0 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -724,14 +724,13 @@ nothing, so pull and `up -d` there afterwards. `.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 +stpvm's (`stpvm`, label `self-hosted`) 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 +swapfile). 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 @@ -739,19 +738,19 @@ job's own `secrets.GITEA_TOKEN`, so a new repo needs no Gitea setup, only 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:** - -``` -cd gitea-runner -bash download.sh # pulls the binary for this CPU -# mint a registration token: Gitea -> Site Administration -> Actions -> Runners -GITEA_RUNNER_REGISTRATION_TOKEN=... ./run.sh # registers once, then daemonises -``` - -The runner lives **outside** Docker on purpose: it runs `docker compose up` -against this stack, so it cannot be a container in it. Registration is one-shot — -`.runner` is the lasting credential; re-registering needs that file deleted _and_ -a fresh token. +**The runners** are installed by the `adamf/stprunner` repo, not from here: +on each VM, `~/deploy/stprunner` and `sudo ./install.sh ` run +gitea-runner (formerly act_runner) as the systemd service `gitea-runner`, +with that host's name, labels and capacity in `hosts/.env` there. Its +README covers a fresh VM, upgrades (Renovate bumps the pinned version) and +renames. Both run in host mode as `adamf`, outside Docker on purpose: the +deploy job runs `docker compose up` against this stack, so it cannot be a +container in it. Since 2026-11-27: gitea-runner v6.0.1, which needs Gitea +1.26.2+ (act_runner 0.2.x could not run `node24` actions such as +`actions/checkout@v5`). Until then each VM ran its own copy of this repo's +old `gitea-runner/` scripts from an `@reboot` crontab line, and stpvm's runner +was registered as `stppi` (the Pi it moved from). Those directories are still +on the VMs, unused, with the old `.runner` files. **Dependency updates (Renovate).** Dependabot is GitHub-only, so `.gitea/workflows/renovate.yaml` runs Renovate on the same runner every Monday diff --git a/README.md b/README.md index d16e737..9db93e9 100644 --- a/README.md +++ b/README.md @@ -215,9 +215,6 @@ Create a `.env` file in the project root. All services read from this file. | `SILVERBULLET_PUBLIC_HOST` | Public notes SilverBullet hostname (defaults to `silverbullet-public`) | | `SILVERBULLET_PUBLIC_PORT` | Public notes SilverBullet port (defaults to `3000`) | | `SILVERBULLET_GIT_INTERVAL` | Seconds between notes pulls (defaults to `300`) | -| `GITEA_RUNNER_HOST` | Gitea runner hostname | -| `GITEA_RUNNER_NAME` | Gitea runner display name | -| `GITEA_RUNNER_REGISTRATION_TOKEN` | Token to register Gitea Actions runner | | `BACKEND_PORT` | Backend port (typically `8080`) | | `BACKEND_HOST` | Backend hostname (use `backend` for Docker) | | `BACKEND_SECRET` | JWT signing secret | @@ -281,9 +278,7 @@ Place at least one `.mp3` file in `icecast2/fallback_music/`. Liquidsoap plays t ### Gitea Runner -1. Download the `act_runner` binary from [Gitea releases](https://gitea.com/gitea/act_runner/releases) and place in `gitea-runner/` -2. Set `GITEA_RUNNER_REGISTRATION_TOKEN` in `.env` -3. The runner registers automatically on first startup +The CI runners (stpvm's and the build VM's) are installed from the `adamf/stprunner` repo, not from here. See its README and "Build VM" in `DEPLOYMENT.md` §7. ## Dev Mode @@ -332,8 +327,6 @@ These files are git-ignored and must be created manually: | `caddy/data/` | Created automatically by Caddy (certificates and their keys) | | `backend/token/` | Created automatically by Docker volume mount | | `icecast2/fallback_music/*.mp3` | Place at least one MP3 file | -| `gitea-runner/act_runner` | Download from Gitea releases | -| `gitea-runner/.runner` | Generated on first runner startup | ## Future Ideas diff --git a/gitea-runner/download.sh b/gitea-runner/download.sh deleted file mode 100755 index 7b3689d..0000000 --- a/gitea-runner/download.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# Fetches the pinned act_runner for this CPU. The runner lives outside docker -# because its deploy job recreates the stack. To upgrade: bump VERSION, delete -# ./act_runner, re-run. -set -euo pipefail - -VERSION="0.2.11" -BASE_URL="https://gitea.com/gitea/act_runner/releases/download/v${VERSION}" - -ARCH=$(uname -m) -case "$ARCH" in - x86_64) ASSET="act_runner-${VERSION}-linux-amd64" ;; - aarch64) ASSET="act_runner-${VERSION}-linux-arm64" ;; - armv7l) ASSET="act_runner-${VERSION}-linux-armv7" ;; - *) - echo "Unsupported architecture: $ARCH" >&2 - exit 1 - ;; -esac - -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -DEST="${SCRIPT_DIR}/act_runner" - -echo "Downloading act_runner v${VERSION} for ${ARCH}..." -curl -fSL "${BASE_URL}/${ASSET}" -o "$DEST" -chmod +x "$DEST" -echo "Downloaded to $DEST" diff --git a/gitea-runner/run.sh b/gitea-runner/run.sh deleted file mode 100755 index b57795d..0000000 --- a/gitea-runner/run.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# Registers (once) and runs the act_runner. Run from this directory. -# Waits for Gitea because registering against a down Gitea fails for good. -# GITEA_RUNNER_REGISTRATION_TOKEN is single-use: .runner is the real -# credential, so to re-register delete .runner and mint a fresh token. -# --labels must match `runs-on:` in .gitea/workflows/. -if [ ! -f ./act_runner ]; then - echo "act_runner binary not found. Downloading..." >&2 - bash "$(dirname "$0")/download.sh" -fi - -echo "Waiting for git.adam-french.co.uk:3000 to respond..." >&2 - -while ! curl -sf http://git.adam-french.co.uk:3000 > /dev/null 2>&1; do - sleep 2 -done - -echo "git.adam-french.co.uk:3000 is up." >&2 - -if [ ! -f .runner ]; then - echo "No .runner file found. Registering runner..." >&2 - ./act_runner register --no-interactive \ - --instance http://git.adam-french.co.uk:3000 \ - --token "${GITEA_RUNNER_REGISTRATION_TOKEN}" \ - --name "${GITEA_RUNNER_NAME:-pi-runner}" \ - --labels self-hosted -fi - -echo "Starting act_runner daemon..." >&2 -exec ./act_runner daemon -