diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index a96ea10..f231f5c 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,8 +1,8 @@ # ============================================================================= # ci.yaml — test the site (site/) on every push that changes it; publish an # image for such pushes to main that pass. Copied from job-tracker's ci.yaml, -# with the same runner and constraints: a self-hosted act_runner on the Pi in -# HOST mode, with git and docker and no other toolchain. So Go and Node run +# with the same runner and constraints: a self-hosted act_runner on the web_server +# host (stpvm) in HOST mode, with git and docker and no other toolchain. So Go and Node run # in `docker run` containers, and the source is fetched with plain git rather # than actions/checkout (which needs Node on the host). # @@ -100,9 +100,10 @@ jobs: SRC: /home/adamf/.cache/usaco-ci/publish-${{ github.sha }} REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} - # The Pi's Docker is 20.10, where plain `docker build` still uses - # the legacy builder, and that rejects the Dockerfile's - # `RUN --mount=type=cache` lines. This switches on BuildKit. + # The Dockerfile's `RUN --mount=type=cache` lines need BuildKit. + # It is the default from Docker 23 (the host runs 29); this was + # needed on the Pi's Docker 20.10, whose plain `docker build` used + # the legacy builder, and is kept for any older daemon. This switches on BuildKit. DOCKER_BUILDKIT: "1" steps: - name: Build and push the image @@ -112,7 +113,7 @@ jobs: rm -rf "$SRC" && mkdir -p "$SRC" git --git-dir="$CACHE" archive --format=tar "$SHA" site | tar -x -C "$SRC" printf '%s' "$REGISTRY_TOKEN" | docker login adam-french.co.uk -u "$REGISTRY_USER" --password-stdin - # Built natively on the Pi, so the image is arm64 — the only + # Built natively on the host, so the image is amd64 — the only # platform it runs on. docker build -t "$IMAGE:$SHA" -t "$IMAGE:latest" "$SRC/site" docker push "$IMAGE:$SHA" diff --git a/site/README.md b/site/README.md index 97dd6f0..d082299 100644 --- a/site/README.md +++ b/site/README.md @@ -100,7 +100,7 @@ A push to `main` that touches `site/` or `.gitea/workflows/` runs `.gitea/workfl Problem commits don't match the path filter, so they never rebuild the image. The webhook brings them in. -By hand on the Pi: +By hand on the host: ``` cd ~/deploy/web_server && docker compose pull usaco && docker compose up -d --no-deps usaco @@ -110,11 +110,11 @@ To pin a version, set `USACO_IMAGE_TAG=` in the site's `.env`. ### One-off setup -The registry setup is shared with job-tracker (see its README, "One-off: registry setup"). The Pi is already logged in, and the same `REGISTRY_USER` and `REGISTRY_TOKEN` work here. +The registry setup is shared with job-tracker (see its README, "One-off: registry setup"). The host is already logged in, and the same `REGISTRY_USER` and `REGISTRY_TOKEN` work here. 1. **CI secrets.** In this repo's Settings → Actions → Secrets, add `REGISTRY_USER` and `REGISTRY_TOKEN`. Use the same values as job-tracker. 2. **A git token for the server.** In Gitea, go to Settings → Applications and create a token with **repository: read and write**. Put it in the site's `.env` as `USACO_GIT_TOKEN`. -3. **The data directory.** On the Pi, in `~/deploy/web_server`, run `mkdir usaco-data && sudo chown 1000:1000 usaco-data`. +3. **The data directory.** On the host, in `~/deploy/web_server`, run `mkdir usaco-data && sudo chown 1000:1000 usaco-data`. 4. **A webhook secret.** Generate one, for example with `openssl rand -hex 32`, and put it in the site's `.env` as `USACO_WEBHOOK_SECRET`. 5. **Deploy web_server** with the `usaco` service and the `/usaco/` route. Then push this repo, so CI publishes the first image. 6. **The webhook.** In this repo's Settings → Webhooks → Add webhook → Gitea, set: