mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
## Summary Builds on #9767 (the `buzz-acceptance` binary, now merged). Based on main. - **Image:** the relay image now carries `buzz-acceptance` next to `buzz-admin` and `buzz-pair-relay`, so no new image or workflow is needed. - **Chart:** `acceptance.enabled=true` adds a CronJob that runs the probe from the relay image. - Requires `image.tag` or `image.digest`. The chart fails to render without one, because the default `Chart.AppVersion` image has no probe. - Every 5 minutes by default, `concurrencyPolicy: Forbid`, `backoffLimit: 0` (a retry would hide a failure), `activeDeadlineSeconds: 240`. - Runs with `acceptance.serviceAccountName` or the namespace default, never the relay's service account. No token mount, no service links. - `acceptance.relayUrl` (defaults to `relayUrl`), `acceptance.stageTimeoutSeconds`. - `acceptance.privateKeySecret.name` is required. Without a key the probe would sign with a new key each run: a members-only relay refuses it, and an open relay joins each new key to every auto-join channel. - `acceptance.statsdAddr` sends DogStatsD metrics. `$(HOST_IP)` expands to the node IP, for a node-local agent. - Every series carries `probe_revision`, the probe's own image (`image.digest`, else `image.tag`), plus `acceptance.tags`. It does not identify the relay build a run reached: during a rollout, or with `acceptance.relayUrl` set, the probe can reach another build. `acceptance.tags` keys must be canonical (lowercase `[a-z0-9_./-]`, starting with a letter, not ending in `_`), so the probe-owned and repeated-key checks see the key Datadog stores. - NIP-FI: minting an assertion is deployment-specific, so the chart takes it as a file. `acceptance.extraInitContainers`, `extraVolumes` and `extraVolumeMounts` let an init container write it, and `acceptance.assertionFile` points the probe at it. These follow the existing relay Pod extension points. - **README:** a new "Acceptance probe" section with an example. The example gives the minter init container the key Secret, keeps credentials in a memory `emptyDir`, and says how to size `activeDeadlineSeconds` against `stageTimeoutSeconds`. - **Chart version:** bumped once at the top of the stack, in https://github.com/block/buzz/pull/9773 ## What got simpler The chart no longer has a "no key" mode, so there is one way to give the probe its identity. The probe reuses the relay image and the chart's existing CronJob, image-identity, label-guard and extension patterns, so it adds no new image, no new publish workflow, and no new extension concept. ## Testing - `tests/acceptance_test.yaml` (helm-unittest): off by default; the default render (relay image, `relayUrl`, no key, no metrics, no extra volumes); a full render with a key Secret, metrics, tags, a digest-pinned image, and an init-container-minted assertion; the chart-owned Datadog version label; the required image tag or digest; `probe_revision` from the probe's image even with another `relayUrl`; no service account inheritance or token mount; and rejection of a missing probe key (also with an assertion file), a tag without a key, an uppercase tag key, a tag key with a space or a trailing `_`, a probe-owned tag key, a repeated tag key, and a chart-owned pod label. The init-container test pins the full `initContainers`, `volumes` and `volumeMounts`. - CI builds the relay image from the changed `Dockerfile`. - A kind run installed the chart and ran one Job against the in-cluster relay: exit 0, all checks passed, no service account token. That run had no key, no assertion and no statsd, so the key and assertion wiring is covered by the render tests above only. ## Follow-ups (not in this PR) - Relay build attribution: the relay does not expose its build id on a public surface yet, so a run can't name the relay build it reached. A deploy gate on these metrics stays report-only until it can. - A canary run against the Rollout's canary Service needs a dial override that keeps the canonical Host (see #9767). 🤖 Generated with [Claude Code](https://claude.com/claude-code) buzz-review-completed --------- Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
195 lines
9.6 KiB
Docker
195 lines
9.6 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
#
|
|
# Public Buzz relay image — published as ghcr.io/block/buzz:<tag>.
|
|
#
|
|
# Builds the `buzz-relay` binary (Rust 1.98) and the `buzz-web` static bundle
|
|
# (pnpm + vite), then assembles them into a small debian-slim runtime with
|
|
# `git` available (the relay shells out to git for repo hydrate / receive-pack
|
|
# / upload-pack — see crates/buzz-relay/src/api/git).
|
|
#
|
|
# Multi-arch is handled by running this same Dockerfile on native amd64 and
|
|
# native arm64 runners (see .github/workflows/docker.yml). The Dockerfile
|
|
# itself is platform-agnostic; do not add --platform pins.
|
|
|
|
ARG RUST_VERSION=1.98
|
|
ARG NODE_VERSION=24
|
|
ARG DEBIAN_VERSION=bookworm
|
|
|
|
# Optional extra CA bundle for builds behind a TLS-intercepting corporate proxy
|
|
# (e.g. a Cloudflare/Zscaler gateway that re-signs TLS). Empty by default, so
|
|
# public CI builds are unaffected. Point it at a PEM file in the build context:
|
|
# docker build --build-arg EXTRA_CA_CERTS=path/to/proxy-ca.pem ...
|
|
# Consumed by the network-touching stages below (cargo + pnpm).
|
|
ARG EXTRA_CA_CERTS=
|
|
|
|
# Optional npm registry for builds where the public registry is unreachable or
|
|
# policy-blocked (e.g. a corporate mirror / Artifactory). Empty default = public
|
|
# npmjs, so public CI builds are unaffected. Consumed by the web-builder stage.
|
|
ARG NPM_REGISTRY=
|
|
|
|
# ─── Stage 1: cargo-chef base ───────────────────────────────────────────────
|
|
FROM rust:${RUST_VERSION}-${DEBIAN_VERSION} AS chef
|
|
# Trust an optional corporate-proxy CA before any network fetch (no-op if unset).
|
|
ARG EXTRA_CA_CERTS
|
|
COPY --chmod=0644 ${EXTRA_CA_CERTS:-Dockerfile} /tmp/extra-ca/src
|
|
RUN if [ -n "${EXTRA_CA_CERTS}" ]; then \
|
|
cp /tmp/extra-ca/src /usr/local/share/ca-certificates/extra-proxy-ca.crt \
|
|
&& update-ca-certificates \
|
|
&& echo "CARGO_HTTP_CAINFO=/etc/ssl/certs/ca-certificates.crt" >> /etc/environment; \
|
|
fi
|
|
ENV CARGO_HTTP_CAINFO=/etc/ssl/certs/ca-certificates.crt
|
|
RUN cargo install cargo-chef --locked --version 0.1.71
|
|
WORKDIR /build
|
|
|
|
# ─── Stage 2: plan dependency graph ─────────────────────────────────────────
|
|
# Only the manifests are needed to compute the recipe; this layer rebuilds
|
|
# only when Cargo.{toml,lock} or crate manifests change, not on every source
|
|
# edit.
|
|
FROM chef AS planner
|
|
COPY . .
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
# ─── Stage 3: cook dependencies, then build the binary ──────────────────────
|
|
FROM chef AS builder
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
cmake \
|
|
pkg-config \
|
|
libssl-dev \
|
|
ca-certificates \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
# Keep enough DWARF for native profilers to resolve optimized code to source
|
|
# locations. The normal runtime strips it below; runtime-debug retains it.
|
|
ENV CARGO_PROFILE_RELEASE_DEBUG=line-tables-only
|
|
COPY --from=planner /build/recipe.json recipe.json
|
|
# Cook the full workspace recipe — relay deps include workspace siblings, so
|
|
# scoping to -p buzz-relay misses transitive deps and re-builds them later.
|
|
RUN cargo chef cook --release --recipe-path recipe.json
|
|
COPY . .
|
|
# Compile immutable artifact identity into the relay. Defaults preserve local
|
|
# and third-party builds that do not run in provenance-aware CI.
|
|
ARG BUZZ_SOURCE_SHA=unknown
|
|
ARG BUZZ_BUILD_ID=local
|
|
ARG BUZZ_BUILD_URL=unknown
|
|
ENV BUZZ_SOURCE_SHA=${BUZZ_SOURCE_SHA} \
|
|
BUZZ_BUILD_ID=${BUZZ_BUILD_ID} \
|
|
BUZZ_BUILD_URL=${BUZZ_BUILD_URL}
|
|
# buzz-acceptance ships in the relay image, so a deployment can run the probe
|
|
# without a second image. The probe can still reach a relay of another build.
|
|
RUN cargo build --release --locked -p buzz-relay --bin buzz-relay \
|
|
-p buzz-admin --bin buzz-admin \
|
|
-p buzz-pair-relay --bin buzz-pair-relay \
|
|
-p buzz-test-client --bin buzz-acceptance
|
|
|
|
# Derive the normal release binaries from the same optimized ELF files as the
|
|
# debug image so the two variants cannot drift at code-generation time.
|
|
FROM builder AS stripped-binaries
|
|
RUN strip target/release/buzz-relay \
|
|
&& strip target/release/buzz-admin \
|
|
&& strip target/release/buzz-pair-relay \
|
|
&& strip target/release/buzz-acceptance
|
|
|
|
# ─── Stage 4: web bundle (pnpm + vite) ──────────────────────────────────────
|
|
# Independent of the Rust layers so a CSS change doesn't bust Rust cache and
|
|
# vice versa.
|
|
FROM node:${NODE_VERSION}-${DEBIAN_VERSION}-slim AS web-builder
|
|
WORKDIR /build
|
|
# Trust an optional corporate-proxy CA so corepack + pnpm can fetch over an
|
|
# intercepting TLS gateway (no-op if EXTRA_CA_CERTS is unset).
|
|
ARG EXTRA_CA_CERTS
|
|
COPY --chmod=0644 ${EXTRA_CA_CERTS:-Dockerfile} /tmp/extra-ca/src
|
|
RUN if [ -n "${EXTRA_CA_CERTS}" ]; then \
|
|
apt-get update && apt-get install -y --no-install-recommends ca-certificates \
|
|
&& cp /tmp/extra-ca/src /usr/local/share/ca-certificates/extra-proxy-ca.crt \
|
|
&& update-ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*; \
|
|
fi
|
|
ENV NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
|
|
# Point npm + corepack at an optional mirror (no-op when NPM_REGISTRY is unset).
|
|
# corepack reads COREPACK_NPM_REGISTRY to fetch the pinned pnpm; pnpm/npm read
|
|
# the .npmrc registry for dependency installs.
|
|
ARG NPM_REGISTRY
|
|
ENV COREPACK_NPM_REGISTRY=${NPM_REGISTRY}
|
|
# When using a mirror, disable corepack's npmjs signature check: the mirror
|
|
# republishes tarballs without the public registry's provenance signatures, so
|
|
# strict verification fails ("No compatible signature found"). Only relaxed on
|
|
# the mirror path — public builds (NPM_REGISTRY unset) keep strict verification.
|
|
RUN if [ -n "${NPM_REGISTRY}" ]; then \
|
|
echo "registry=${NPM_REGISTRY}" > /build/.npmrc \
|
|
&& echo "COREPACK_INTEGRITY_KEYS=0" >> /etc/environment; \
|
|
fi
|
|
ENV COREPACK_INTEGRITY_KEYS=${NPM_REGISTRY:+0}
|
|
RUN corepack enable
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
COPY patches/ patches/
|
|
COPY web/package.json web/
|
|
COPY admin-web/package.json admin-web/
|
|
RUN pnpm install --frozen-lockfile --filter buzz-web --filter buzz-admin-web
|
|
COPY web/ web/
|
|
COPY previews/invite-video/buzz-invite-loop.mp4 previews/invite-video/buzz-invite-poster.png previews/invite-video/
|
|
COPY admin-web/ admin-web/
|
|
RUN pnpm -C web build && pnpm -C admin-web build
|
|
|
|
# ─── Stage 5: shared runtime ────────────────────────────────────────────────
|
|
FROM debian:${DEBIAN_VERSION}-slim AS runtime-base
|
|
|
|
# OCI annotations: required for GHCR to auto-link the image to this repo and
|
|
# inherit its visibility. org.opencontainers.image.source is the load-bearing
|
|
# one — without it GHCR keeps the image private even when the repo is public.
|
|
LABEL org.opencontainers.image.title="Buzz" \
|
|
org.opencontainers.image.description="WebSocket relay server for the Buzz communications platform" \
|
|
org.opencontainers.image.source="https://github.com/block/buzz" \
|
|
org.opencontainers.image.url="https://github.com/block/buzz" \
|
|
org.opencontainers.image.documentation="https://github.com/block/buzz#readme" \
|
|
org.opencontainers.image.licenses="Apache-2.0"
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
curl \
|
|
git \
|
|
openssl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& groupadd --system --gid 1000 buzz \
|
|
&& useradd --system --uid 1000 --gid 1000 --home-dir /var/lib/buzz \
|
|
--create-home --shell /usr/sbin/nologin buzz
|
|
|
|
COPY --from=web-builder /build/web/dist /srv/buzz/web
|
|
COPY --from=web-builder /build/admin-web/dist /srv/buzz/admin-web
|
|
|
|
# The invite landing page is always served from the bundled web UI. Repository
|
|
# browser routes require the separate BUZZ_SERVE_GIT_WEB_GUI=true opt-in. The
|
|
# admin bundle is inert until BUZZ_ADMIN_HOST is configured.
|
|
ENV BUZZ_WEB_DIR=/srv/buzz/web \
|
|
BUZZ_ADMIN_WEB_DIR=/srv/buzz/admin-web
|
|
|
|
# 3000: app (WS + REST) · 8080: /_liveness, /_readiness · 9102: /metrics
|
|
EXPOSE 3000 8080 9102
|
|
|
|
# deploy/compose mounts a volume here; pre-created so it inherits buzz:buzz.
|
|
RUN mkdir -p /data/git && chown buzz:buzz /data/git
|
|
|
|
USER buzz:buzz
|
|
WORKDIR /var/lib/buzz
|
|
|
|
ENTRYPOINT ["/usr/local/bin/buzz-relay"]
|
|
|
|
# Optimized binaries with line-table debug information for native profiling.
|
|
# Published under debug-* tags; runtime behavior otherwise matches the normal
|
|
# image exactly.
|
|
FROM runtime-base AS runtime-debug
|
|
COPY --from=builder /build/target/release/buzz-relay /usr/local/bin/buzz-relay
|
|
COPY --from=builder /build/target/release/buzz-admin /usr/local/bin/buzz-admin
|
|
COPY --from=builder /build/target/release/buzz-pair-relay /usr/local/bin/buzz-pair-relay
|
|
COPY --from=builder /build/target/release/buzz-acceptance /usr/local/bin/buzz-acceptance
|
|
|
|
# Keep the stripped runtime as the final/default Dockerfile target so existing
|
|
# `docker build .` callers and release tags retain their current behavior.
|
|
FROM runtime-base AS runtime
|
|
COPY --from=stripped-binaries /build/target/release/buzz-relay /usr/local/bin/buzz-relay
|
|
COPY --from=stripped-binaries /build/target/release/buzz-admin /usr/local/bin/buzz-admin
|
|
COPY --from=stripped-binaries /build/target/release/buzz-pair-relay /usr/local/bin/buzz-pair-relay
|
|
COPY --from=stripped-binaries /build/target/release/buzz-acceptance /usr/local/bin/buzz-acceptance
|