Skip to content

Commit f35a0ec

Browse files
RoyLinRoyLin
authored andcommitted
ci: GHCR release uses the validated build pattern (binary + slim image)
Switch image.yml + deploy/Dockerfile from the unverified multi-stage build to the pattern validated end-to-end on KVM: cargo build --release -> stage binary -> slim ubuntu:24.04 runtime image (glibc-matched to ubuntu-latest CI runner). Verified: builds + runs (eBPF-load error, not glibc). Closes the unverified-release-path loose end.
1 parent 45185dd commit f35a0ec

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

.github/workflows/image.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: image
22

3-
# Canonical release: on a version tag, build the collector image from source (clean-room,
4-
# reproducible — unlike a manual host build) and push to GHCR. The internal A3S registry
5-
# (what the cluster pulls from) is then fed by promoting/mirroring this image.
3+
# Canonical release: on a version tag, build the collector clean-room (the eBPF crate +
4+
# userspace binary) and push the runtime image to GHCR. The internal A3S registry (what the
5+
# egress-constrained cluster pulls) is fed by promoting/mirroring this image.
66
on:
77
push:
88
tags: ['v*']
@@ -14,9 +14,16 @@ permissions:
1414

1515
jobs:
1616
image:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-latest # 24.04 — glibc matches the ubuntu:24.04 runtime base
1818
steps:
1919
- uses: actions/checkout@v4
20+
- uses: dtolnay/rust-toolchain@nightly
21+
with:
22+
components: rust-src # build-std for the bpfel-unknown-none eBPF target
23+
- run: cargo install bpf-linker --locked
24+
- run: cargo build --release -p a3s-observer-collector
25+
- name: stage binary (small build context)
26+
run: mkdir -p dist && cp target/release/a3s-observer-collector dist/
2027
- uses: docker/setup-buildx-action@v3
2128
- uses: docker/login-action@v3
2229
with:
@@ -32,8 +39,8 @@ jobs:
3239
type=ref,event=tag
3340
- uses: docker/build-push-action@v6
3441
with:
35-
context: .
36-
file: deploy/Dockerfile # multi-stage: builds the eBPF + collector from source
42+
context: dist
43+
file: deploy/Dockerfile
3744
push: true
3845
tags: ${{ steps.meta.outputs.tags }}
3946
labels: ${{ steps.meta.outputs.labels }}

deploy/Dockerfile

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
# Build the collector (with the eBPF toolchain) then ship just the binary.
2-
# Build from the crate root: docker build -f deploy/Dockerfile -t a3s-observer:0.2.0 .
1+
# Runtime image for a3s-observer-collector.
32
#
4-
# bpf-linker borrows rustc's bundled LLVM (aya-rustc-llvm-proxy), so no system LLVM is
5-
# needed; build.rs compiles the eBPF crate with the nightly toolchain + rust-src.
6-
7-
FROM rust:1-bookworm AS build
8-
RUN rustup toolchain install nightly --component rust-src \
9-
&& cargo install bpf-linker
10-
WORKDIR /src
11-
COPY . .
12-
RUN cargo build --release -p a3s-observer-collector
13-
14-
FROM debian:bookworm-slim
15-
COPY --from=build /src/target/release/a3s-observer-collector /usr/local/bin/a3s-observer-collector
3+
# Two steps (this is what .github/workflows/image.yml does, and what was validated by hand):
4+
# 1. build the binary: cargo build --release -p a3s-observer-collector
5+
# 2. stage + build: mkdir -p dist && cp target/release/a3s-observer-collector dist/
6+
# docker build -f deploy/Dockerfile -t a3s-observer dist
7+
#
8+
# The base must match the build host's glibc — the binary is dynamically linked. CI builds on
9+
# ubuntu-latest (24.04) and ships on ubuntu:24.04; keep them in lockstep (or build static musl
10+
# for a distroless/scratch base).
11+
FROM ubuntu:24.04
12+
COPY a3s-observer-collector /usr/local/bin/a3s-observer-collector
1613
ENV A3S_OBSERVER_JSON=1
1714
ENTRYPOINT ["/usr/local/bin/a3s-observer-collector"]

0 commit comments

Comments
 (0)