Skip to content

Commit be3a4b8

Browse files
authored
build(agents): build and publish the Buzz agent images from this repository (#44)
Move the buzz-agent and buzz-sandbox-reaper images from voltagecloud/images (at f944157) to voltage/images/, so this repository builds them and pushes them to Voltage's ECR from its own CI on merge to main. The paths are Voltage-only, so upstream block/buzz syncs do not conflict with them. The images now compile the checked-out commit instead of a git fetch of a pinned BUZZ_REVISION. The build context is the repository root, and each Dockerfile copies the source with COPY . . as Dockerfile.sprig does. The BUZZ_REVISION argument and its checks are gone; the base image digests, users, and stages are unchanged. The agent image copies its scripts from voltage/images/buzz-agent/. Each Dockerfile has a Dockerfile.dockerignore next to it, which BuildKit reads instead of the root .dockerignore. Each file starts from the root .dockerignore and also excludes what cargo build --locked does not read, such as apps/, web/, desktop/, and mobile/. It keeps every root Cargo workspace member and the scripts/ and test-fixtures/ files that crates embed. The agent file adds back only the files that its Dockerfile copies, as the old per-image .dockerignore did. .github/workflows/voltage-agent-images.yml selects the images whose inputs changed. On pull requests it lints the Dockerfiles (hadolint, BuildKit checks) and builds each selected image for linux/amd64 and linux/arm64 on native runners without a push. It then runs the agent image tests, the reaper binary, and a relay smoke test (voltage/images/test-relay-image.sh). On main, and on manual runs on main, each platform is pushed by digest. A merge job then creates a manifest list tagged with the full commit SHA, reports an existing tag instead of failing (ECR tags are immutable), and writes the manifest list digest to the job summary. The repository and its logs are public, so pull request jobs have no AWS access. Only the publish and merge jobs request an OIDC token, and they run only on main. They assume github-buzz-ecr-push (voltage-terraform block#982), which trusts only repo:voltagecloud/buzz:ref:refs/heads/main and can push to and read only the Buzz repositories. The AWS_ACCOUNT_ID repository secret supplies the account ID, so the ID is not in the repository and is masked in the logs. The secret must exist before the first publish. The same workflow also builds the Buzz relay from the upstream root Dockerfile (target runtime, with the BUZZ_SOURCE_SHA, BUZZ_BUILD_ID, and BUZZ_BUILD_URL build arguments that docker.yml passes), and pushes it to the buzz-relay ECR repository with the same digest, manifest list, and existing-tag flow and the same role. voltage-terraform block#983 creates that repository and adds it to the role. Its path filter lists only what the root Dockerfile reads. The root Dockerfile, the root .dockerignore, and the upstream workflows are unchanged. Prod pins the relay digest in voltagecloud/cd. Signed-off-by: Tee8z <[email protected]>
1 parent 37af94b commit be3a4b8

41 files changed

Lines changed: 6409 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/voltage-agent-images.yml‎

Lines changed: 411 additions & 0 deletions
Large diffs are not rendered by default.

‎voltage/images/README.md‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Voltage images
2+
3+
This directory holds the container images that Voltage builds from this fork for Buzz remote agents.
4+
It is Voltage-only, so upstream block/buzz syncs do not conflict with it.
5+
The agent images moved here from voltagecloud/images at `f944157`.
6+
The same workflow also builds the Buzz relay image from the upstream root `Dockerfile`; see [The relay image](#the-relay-image).
7+
8+
| Image | Contents | ECR repository |
9+
| --- | --- | --- |
10+
| [buzz-agent](buzz-agent/README.md) | Remote developer agent Sandbox: the `sprig` harness, Codex and Claude ACP adapters, and developer tools. It also runs as the `buzz-agent-gate` DaemonSet. | `voltage-buzz-agent-staging` |
11+
| [buzz-sandbox-reaper](buzz-sandbox-reaper/Dockerfile) | In-cluster reaper for ended and orphaned agent Sandboxes (`buzz-sandbox-reaper reconcile`) | `voltage-buzz-sandbox-reaper-staging` |
12+
| [buzz-relay](#the-relay-image) | Buzz relay, admin, and pair relay binaries with the web bundles, from the root `Dockerfile` | `buzz-relay` |
13+
14+
Each image compiles the Buzz crates of the commit it is built from.
15+
The build context is the repository root.
16+
For the two agent images, BuildKit reads the `Dockerfile.dockerignore` next to each Dockerfile instead of the root `.dockerignore`.
17+
These files keep only the Cargo workspace and, for `buzz-agent`, the files that its Dockerfile copies from `voltage/images/buzz-agent`.
18+
19+
## Publishing
20+
21+
[`.github/workflows/voltage-agent-images.yml`](../../.github/workflows/voltage-agent-images.yml) runs when a change touches the files that an image reads.
22+
Its first job selects only the images whose inputs changed; manual runs build all of them.
23+
24+
- Pull requests: hadolint and BuildKit checks, then a build of each selected image for `linux/amd64` and `linux/arm64` on native runners, without a push.
25+
The workflow tests the agent image on both platforms, runs the reaper binary, and smoke-tests the relay image with [`test-relay-image.sh`](test-relay-image.sh).
26+
These jobs have no AWS access.
27+
- `main`: each platform builds on its native runner and is pushed by digest.
28+
A merge job then creates one manifest list per image, tagged with the full commit SHA.
29+
ECR tags are immutable; if the tag exists, the job reports it and does not replace it.
30+
The job summary lists the manifest list digest for each image.
31+
- Manual runs (`workflow_dispatch`) publish only on `main`.
32+
33+
The voltage-terraform `v2/environments/staging` root creates the two agent ECR repositories; `v2/environments/prod` creates `buzz-relay`.
34+
Publishing assumes the `github-buzz-ecr-push` IAM role (voltage-terraform `v2/environments/github`).
35+
The role trusts only `repo:voltagecloud/buzz:ref:refs/heads/main` and can push to and read only these three repositories.
36+
The repository secret `AWS_ACCOUNT_ID` supplies the account ID, so the account ID is not in the repository and is masked in the public logs.
37+
38+
## Deploying a digest
39+
40+
Pin the manifest list digest from the job summary (`<repository>@sha256:<digest>`), never a tag or a local image ID.
41+
42+
| Image | Where to pin it |
43+
| --- | --- |
44+
| `voltage-buzz-agent-staging` | The Buzz Kubernetes provider `image`, and `image.digest` in voltagecloud/cd `staging/values/infra-utils/buzz-agent-gate.yaml` |
45+
| `voltage-buzz-sandbox-reaper-staging` | `image.digest` in voltagecloud/cd `staging/values/infra-utils/buzz-sandbox-reaper.yaml` |
46+
| `buzz-relay` | `image.repository` and `image.digest` in voltagecloud/cd `prod/values/buzz/prod.yaml` |
47+
48+
The voltage-terraform admission policy admits only digest-pinned images from `voltage-buzz-agent-staging` in developer namespaces.
49+
50+
## Build and test locally
51+
52+
Run from the repository root. The Rust build takes a long time; the Dockerfiles set `CARGO_BUILD_JOBS=2`.
53+
54+
```bash
55+
docker buildx build --check -f voltage/images/buzz-agent/Dockerfile .
56+
docker buildx build --check -f voltage/images/buzz-sandbox-reaper/Dockerfile .
57+
58+
docker build --platform linux/amd64 -f voltage/images/buzz-sandbox-reaper/Dockerfile -t buzz-sandbox-reaper:local .
59+
docker run --rm buzz-sandbox-reaper:local --help
60+
61+
docker build --platform linux/amd64 -f voltage/images/buzz-agent/Dockerfile -t buzz-agent:local .
62+
bash voltage/images/buzz-agent/test-image.sh buzz-agent:local
63+
```
64+
65+
[buzz-agent/README.md](buzz-agent/README.md#build-and-test) lists the other agent image tests.
66+
67+
## The relay image
68+
69+
The relay image is the upstream Buzz relay: the root [`Dockerfile`](../../Dockerfile), target `runtime`, with the root `.dockerignore`.
70+
Upstream publishes it to GHCR with [`.github/workflows/docker.yml`](../../.github/workflows/docker.yml); this fork does not change that file or the Dockerfile.
71+
The Voltage workflow builds the same Dockerfile with the same `BUZZ_SOURCE_SHA`, `BUZZ_BUILD_ID`, and `BUZZ_BUILD_URL` build arguments and pushes it to the `buzz-relay` ECR repository, tagged with the full commit SHA.
72+
It does not publish the `runtime-debug` variant.
73+
Production runs the relay from this repository, so prod pins the `buzz-relay` manifest list digest in voltagecloud/cd.
74+
75+
```bash
76+
docker buildx build --check .
77+
docker build --platform linux/amd64 --target runtime -t buzz-relay:local .
78+
bash voltage/images/test-relay-image.sh buzz-relay:local
79+
```
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# syntax=docker/dockerfile:1.7
2+
# Build from the repository root so the image packages the checked-out Buzz
3+
# source; Dockerfile.dockerignore next to this file selects the context.
4+
FROM rust:1.95-alpine3.22@sha256:064dfc925d68d1a63f4fd2871bd7dc6e6ea56692989a487185855d62885d90aa AS source
5+
RUN apk add --no-cache bash build-base cmake git musl-dev openssl-dev \
6+
openssl-libs-static perl pkgconf protoc python3 procps
7+
WORKDIR /build
8+
ENV CARGO_INCREMENTAL=0 CARGO_BUILD_JOBS=2
9+
COPY . .
10+
FROM source AS package-checks
11+
RUN apk add --no-cache tini \
12+
&& tini -s -- cargo test --locked -p sprig -p buzz-acp -p buzz-agent -p buzz-dev-mcp -- --test-threads=1
13+
14+
FROM source AS builder
15+
RUN cargo build --locked --profile sprig -p sprig \
16+
&& strip target/sprig/sprig
17+
18+
FROM rust:1.97.1-slim-trixie@sha256:8e8cf8f7fd54a2d23d5a743b3a03f56e26b6c774276c33fa0595111704ebb15c AS development-rust
19+
20+
FROM node:22-trixie-slim@sha256:154ba2f4d6fec323d28e4f4bb86bba4677f1223391a1979cf521304e03a98dfa
21+
LABEL maintainer="Voltage <[email protected]>"
22+
RUN apt-get update \
23+
&& apt-get install -y --no-install-recommends bash ca-certificates curl git gh gnupg openssh-client socat tini \
24+
build-essential clang cmake pkg-config libssl-dev protobuf-compiler \
25+
python3 python3-venv python3-pip golang-go postgresql-client sqlite3 \
26+
jq unzip time procps just awscli \
27+
&& rm -rf /var/lib/apt/lists/* \
28+
&& groupadd --gid 10001 agent \
29+
&& useradd --uid 10001 --gid 10001 --create-home --home-dir /home/agent agent
30+
COPY --from=development-rust /usr/local/rustup /opt/rustup
31+
COPY --from=development-rust /usr/local/cargo/bin /usr/local/bin
32+
ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/home/agent/.cargo CARGO_BUILD_JOBS=2
33+
# Release assets are public and pinned by checksum per architecture;
34+
# credentials enter only at runtime.
35+
ARG TARGETARCH
36+
RUN case "$TARGETARCH" in \
37+
amd64) via=x86_64 gitleaks=x64 sccache=x86_64 \
38+
via_sha=9e5a7f9384cacda29061d814e9397e7b6d90a72ee4663775362978ac9b65d8b7 \
39+
op_sha=198b05dcf9a0972778ce5a4e262c459979b0c837257b5da65e2fba6187734226 \
40+
gitleaks_sha=551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb \
41+
depot_sha=7a469c767bd3b7e67b3174f91af9c6315fea0ced4871948ee9d41a006fb2347e \
42+
sccache_sha=45f1447fbe231e3037bde351ef70677dd212216c8d62ae7ca409fecc4d6acc89 ;; \
43+
arm64) via=arm64 gitleaks=arm64 sccache=aarch64 \
44+
via_sha=26cc174802c875424b9846a398d4b2d890b911506f7c574dee96859620caa535 \
45+
op_sha=7b5c361a23e738a3969cf676960f4843af4aa9aa68dbec23d18a9134da428ba3 \
46+
gitleaks_sha=e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080 \
47+
depot_sha=042d846f544919e6b5bcb328387b1963af4e298bfa441a41f36bc46663202f2b \
48+
sccache_sha=2b3284d5da3b46a47dc4229e75bb7b88ac4aa99c8d754fb7d2f84997e5a4354a ;; \
49+
*) echo "Unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \
50+
esac \
51+
&& curl -fsSL "https://github.com/tee8z/via/releases/download/v0.6.1/via-linux-$via.tar.gz" -o /tmp/via.tar.gz \
52+
&& echo "$via_sha /tmp/via.tar.gz" | sha256sum -c - \
53+
&& mkdir -p /opt/agent-tools \
54+
&& tar -xzf /tmp/via.tar.gz -C /opt/agent-tools via \
55+
&& curl -fsSL "https://cache.agilebits.com/dist/1P/op2/pkg/v2.34.0/op_linux_${TARGETARCH}_v2.34.0.zip" -o /tmp/op.zip \
56+
&& echo "$op_sha /tmp/op.zip" | sha256sum -c - \
57+
&& unzip -p /tmp/op.zip op > /usr/local/bin/op \
58+
&& chmod 0755 /usr/local/bin/op \
59+
&& curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_$gitleaks.tar.gz" -o /tmp/gitleaks.tar.gz \
60+
&& echo "$gitleaks_sha /tmp/gitleaks.tar.gz" | sha256sum -c - \
61+
&& tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks \
62+
&& curl -fsSL "https://github.com/depot/cli/releases/download/v2.102.18/depot_2.102.18_linux_${TARGETARCH}.tar.gz" -o /tmp/depot.tar.gz \
63+
&& echo "$depot_sha /tmp/depot.tar.gz" | sha256sum -c - \
64+
&& tar -xzf /tmp/depot.tar.gz -C /usr/local/bin --strip-components=1 bin/depot \
65+
&& curl -fsSL "https://github.com/mozilla/sccache/releases/download/v0.18.0/sccache-v0.18.0-$sccache-unknown-linux-musl.tar.gz" -o /tmp/sccache.tar.gz \
66+
&& echo "$sccache_sha /tmp/sccache.tar.gz" | sha256sum -c - \
67+
&& tar -xzf /tmp/sccache.tar.gz -C /usr/local/bin --strip-components=1 "sccache-v0.18.0-$sccache-unknown-linux-musl/sccache" \
68+
&& rm /tmp/via.tar.gz /tmp/op.zip /tmp/gitleaks.tar.gz /tmp/depot.tar.gz /tmp/sccache.tar.gz
69+
COPY voltage/images/buzz-agent/checkpoint-gitleaks.toml /opt/agent-tools/checkpoint-gitleaks.toml
70+
WORKDIR /opt/buzz-runtimes
71+
COPY voltage/images/buzz-agent/package.json voltage/images/buzz-agent/package-lock.json ./
72+
RUN npm ci --omit=dev --no-audit --no-fund \
73+
# This image is Debian (glibc), not Alpine (musl).
74+
&& rm -rf node_modules/@anthropic-ai/*-linux-*-musl \
75+
&& npm cache clean --force
76+
COPY --from=builder /build/target/sprig/sprig /usr/local/bin/sprig
77+
COPY --chmod=0755 voltage/images/buzz-agent/account.py /usr/local/bin/buzz-agent-account
78+
COPY --chmod=0755 voltage/images/buzz-agent/profile.py /usr/local/bin/buzz-agent-profile
79+
COPY --chmod=0755 voltage/images/buzz-agent/cache.py /usr/local/bin/buzz-agent-cache
80+
COPY --chmod=0755 voltage/images/buzz-agent/checkpoint.py /usr/local/bin/buzz-agent-checkpoint
81+
COPY --chmod=0755 voltage/images/buzz-agent/heavy.py /usr/local/bin/buzz-heavy
82+
COPY --chmod=0755 voltage/images/buzz-agent/worker.py /usr/local/bin/buzz-agent-worker
83+
COPY --chmod=0755 voltage/images/buzz-agent/subagent.py /usr/local/bin/buzz-subagent
84+
COPY --chmod=0644 voltage/images/buzz-agent/subagents.md /etc/buzz-agent/subagents.md
85+
COPY --chmod=0755 voltage/images/buzz-agent/heavy-bin/ /opt/buzz-heavy/bin/
86+
COPY --chmod=0755 voltage/images/buzz-agent/gh.sh /usr/local/bin/gh
87+
COPY --chmod=0755 voltage/images/buzz-agent/via.sh /usr/local/bin/via
88+
COPY --chmod=0755 voltage/images/buzz-agent/gpg.sh /usr/local/bin/buzz-gpg
89+
COPY --chmod=0755 voltage/images/buzz-agent/entrypoint.sh /usr/local/bin/sprig-entrypoint
90+
COPY --chmod=0755 voltage/images/buzz-agent/setup.js /usr/local/bin/buzz-agent-setup
91+
RUN ln -s /usr/local/bin/buzz-agent-setup /usr/local/bin/buzz-setup-complete \
92+
&& ln -s /usr/local/bin/buzz-heavy /usr/local/bin/buzz-agent-gate \
93+
&& for name in buzz-acp buzz-agent buzz-dev-mcp rg tree buzz git-credential-nostr git-sign-nostr; do \
94+
ln -s sprig "/usr/local/bin/$name"; \
95+
done
96+
# /opt/buzz-heavy/bin gates compiling cargo and go commands through buzz-heavy.
97+
ENV HOME=/home/agent PATH=/opt/buzz-heavy/bin:/opt/buzz-runtimes/node_modules/.bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin
98+
WORKDIR /home/agent
99+
USER 10001:10001
100+
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/sprig-entrypoint"]
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Build outputs
2+
target/
3+
**/target/
4+
desktop/src-tauri/target/
5+
6+
# Native non-relay UI builds (not part of the public image)
7+
desktop/
8+
mobile/
9+
10+
# Node artifacts (built inside the image; host outputs would invalidate cache)
11+
node_modules/
12+
**/node_modules/
13+
web/dist/
14+
15+
# VCS, IDE, scratch
16+
.git/
17+
.github/
18+
.gitignore
19+
.gitattributes
20+
.vscode/
21+
.idea/
22+
.scratch/
23+
24+
# Local environment / secrets — never want these in the build context
25+
.env
26+
.env.*
27+
!.env.example
28+
*.pem
29+
*.key
30+
secrets/
31+
32+
# OS junk
33+
.DS_Store
34+
Thumbs.db
35+
36+
# CI artifacts and tooling that the image doesn't need
37+
.cache/
38+
coverage/
39+
dist/
40+
playwright-report/
41+
test-results/
42+
bin/
43+
sidecars/
44+
45+
# Docs the image doesn't ship. examples/ stays — examples/countdown-bot is
46+
# a Cargo workspace member, so cargo-chef needs its manifest. Markdown files
47+
# inside crates (Cargo.toml `readme = ...`) likewise need to be present to
48+
# avoid manifest warnings; the savings from excluding them are negligible.
49+
docs/
50+
51+
# Old Dockerfile noise (this Dockerfile is THE source of truth now)
52+
docker-compose.yml
53+
docker-compose.*.yml
54+
prometheus.yml
55+
56+
# --- Voltage agent images ---------------------------------------------------
57+
# The lines above copy the root .dockerignore. The lines below also exclude
58+
# what `cargo build --locked` does not read. Keep the workspace manifest and
59+
# lockfile, .cargo/, rust-toolchain.toml, every root workspace member (crates/,
60+
# examples/), and scripts/ and test-fixtures/, which crates include at
61+
# compile time.
62+
web/
63+
apps/
64+
admin-web/
65+
benchmarks/
66+
deploy/
67+
migrations/
68+
perf/
69+
PLANS/
70+
patches/
71+
schema/
72+
script/
73+
.agents/
74+
.claude/
75+
.codex/
76+
.config/
77+
.goose/
78+
.hermit/
79+
.intersect/
80+
.release/
81+
**/__pycache__/
82+
voltage/
83+
# This image also packages the files below. The other files in
84+
# voltage/images/buzz-agent (tests, docs, examples) stay out of the context.
85+
!voltage/images/buzz-agent/package.json
86+
!voltage/images/buzz-agent/package-lock.json
87+
!voltage/images/buzz-agent/entrypoint.sh
88+
!voltage/images/buzz-agent/setup.js
89+
!voltage/images/buzz-agent/account.py
90+
!voltage/images/buzz-agent/profile.py
91+
!voltage/images/buzz-agent/cache.py
92+
!voltage/images/buzz-agent/checkpoint.py
93+
!voltage/images/buzz-agent/checkpoint-gitleaks.toml
94+
!voltage/images/buzz-agent/gh.sh
95+
!voltage/images/buzz-agent/via.sh
96+
!voltage/images/buzz-agent/gpg.sh
97+
!voltage/images/buzz-agent/heavy.py
98+
!voltage/images/buzz-agent/heavy-bin/
99+
!voltage/images/buzz-agent/worker.py
100+
!voltage/images/buzz-agent/subagent.py
101+
!voltage/images/buzz-agent/subagents.md

0 commit comments

Comments
 (0)