| 1 | #!/usr/bin/env bash |
| 2 | # Build the shared anvil runner image(s) — what BOTH CI jobs and agent sessions |
| 3 | # execute in. |
| 4 | # |
| 5 | # Two tags from one Dockerfile, differing only in base: |
| 6 | # |
| 7 | # anvil-runner:latest debian:bookworm-slim general purpose, the default |
| 8 | # anvil-runner:rust rust:1.95-bookworm carries the Rust toolchain |
| 9 | # |
| 10 | # There is deliberately no registry push: anvil resolves its default image from |
| 11 | # the LOCAL image store and treats a failed pull as non-fatal when the image is |
| 12 | # already present. So this must run on whichever host owns the Docker daemon |
| 13 | # anvil talks to — the VPS in production, your machine in dev. |
| 14 | # |
| 15 | # ./deploy/runner/build.sh # both tags |
| 16 | # ./deploy/runner/build.sh latest # just the slim one |
| 17 | # ./deploy/runner/build.sh rust # just the toolchain one |
| 18 | set -euo pipefail |
| 19 | |
| 20 | cd "$(dirname "$0")" |
| 21 | |
| 22 | NAME="${ANVIL_RUNNER_IMAGE:-anvil-runner}" |
| 23 | CHANNEL="${CLAUDE_CHANNEL:-stable}" |
| 24 | |
| 25 | build() { |
| 26 | local tag="$1" base="$2" |
| 27 | echo "==> building ${NAME}:${tag} (base ${base}, claude channel ${CHANNEL})" |
| 28 | docker build \ |
| 29 | --build-arg "BASE=${base}" \ |
| 30 | --build-arg "CLAUDE_CHANNEL=${CHANNEL}" \ |
| 31 | -t "${NAME}:${tag}" \ |
| 32 | . |
| 33 | } |
| 34 | |
| 35 | case "${1:-all}" in |
| 36 | latest) build latest debian:bookworm-slim ;; |
| 37 | rust) build rust rust:1.95-bookworm ;; |
| 38 | all) |
| 39 | build latest debian:bookworm-slim |
| 40 | build rust rust:1.95-bookworm |
| 41 | ;; |
| 42 | *) |
| 43 | echo "usage: $0 [latest|rust|all]" >&2 |
| 44 | exit 64 |
| 45 | ;; |
| 46 | esac |
| 47 | |
| 48 | echo |
| 49 | echo "==> done" |
| 50 | docker images "${NAME}" --format ' {{.Repository}}:{{.Tag}} {{.Size}}' |
| 51 | echo |
| 52 | echo "Point anvil at it in anvil.toml if you use a non-default name:" |
| 53 | echo " [ci]" |
| 54 | echo " default_image = \"${NAME}:latest\"" |
| 55 | echo " [agent]" |
| 56 | echo " image = \"${NAME}:latest\"" |