GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [plan] Add BuildKit cache mounts to Dockerfile and CI local cache for self-hosted runner · Issue #270 · sands-lab/h3llo Closed Labels agentize:planIssues with implementation plans DescriptionNow I have all the information I need. Let me understand the user's resolve selections:
Let me verify compatibility and produce the unified plan. Implementation Plan: BuildKit Cache Mounts and CI Local CacheTable of Contents
GoalAdd BuildKit Out of scope:
Codebase AnalysisFile changes:
Implementation StepsStep 1: Rewrite Dockerfile — Remove cargo-chef, add cache mounts, update header
Code Draft-# Multi-stage Dockerfile for h3llo BareUDP VPN -# Debian builder + Alpine runtime for static musl binaries +# syntax=docker/dockerfile:1 +# Multi-stage Dockerfile for h3llo BareUDP VPN (requires Docker Buildx) +# Debian builder + Alpine runtime for static musl binaries. +# Uses BuildKit cache mounts to persist cargo registry and compilation +# artifacts across builds on the same host. # # Targets: # runtime (default) - Minimal Alpine production image # test - Adds diagnostic tools for integration tests # # Usage: -# docker build --target runtime -t h3llo:latest . -# docker build --target test -t h3llo:test . +# docker buildx build --target runtime -t h3llo:latest --load . +# docker buildx build --target test -t h3llo:test --load . -# Stage 1: Chef - Install cargo-chef with Debian (supports libclang dynamic loading) -FROM rust:slim-trixie AS chef +# Stage 1: Toolchain - Debian with musl cross-compilation and boring-sys deps +FROM rust:slim-trixie AS toolchain # Install boring-sys dependencies and curl/xz for downloading musl toolchain RUN apt-get update && apt-get install -y \ curl xz-utils \ cmake make perl golang-go git \ clang libclang-dev \ && rm -rf /var/lib/apt/lists/* # Download musl cross-compilation toolchain from GitHub (auto-redirects to latest release) # Source: https://github.com/cross-tools/musl-cross RUN curl -sSfL https://github.com/cross-tools/musl-cross/releases/latest/download/x86_64-unknown-linux-musl.tar.xz \ | tar -xJf - -C /opt ENV PATH="/opt/x86_64-unknown-linux-musl/bin:$PATH" # Add musl target RUN rustup target add x86_64-unknown-linux-musl # Configure compilers for musl target ENV CC_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-gcc ENV CXX_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-g++ ENV AR_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-ar ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-unknown-linux-musl-gcc -RUN cargo install cargo-chef --locked WORKDIR /app -# Stage 2: Planner - Generate dependency recipe -FROM chef AS planner -COPY Cargo.toml Cargo.lock ./ -COPY src ./src -RUN cargo chef prepare --recipe-path recipe.json - -# Stage 3: Builder - Build dependencies then application -FROM chef AS builder -COPY --from=planner /app/recipe.json recipe.json -# Build dependencies (cached as long as recipe.json unchanged) -RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json -# Build application and test binaries +# Stage 2: Builder - Build application and test binaries +FROM toolchain AS builder COPY Cargo.toml Cargo.lock ./ COPY src ./src COPY tests ./tests -RUN cargo build --release --target x86_64-unknown-linux-musl --bin h3llo && \ +# Cache mounts persist cargo registry/git and compilation artifacts across builds. +# Target dir is a cache mount so artifacts are NOT stored in image layers — +# we must copy them to /app/out/ within this same RUN instruction. +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/usr/local/cargo/git/db \ + --mount=type=cache,target=/app/target,sharing=locked \ + set -e && \ + cargo build --release --target x86_64-unknown-linux-musl --bin h3llo && \ cargo test --test integration-container-tun --release --target x86_64-unknown-linux-musl --no-run && \ cargo test --test integration-container-route --release --target x86_64-unknown-linux-musl --no-run && \ - strip /app/target/x86_64-unknown-linux-musl/release/h3llo -# Copy test binaries to known location (they have hash suffixes in deps/) -RUN mkdir -p /app/test-binaries && \ - find /app/target/x86_64-unknown-linux-musl/release/deps -name 'integration_container_tun-*' -type f ! -name '*.d' -exec cp {} /app/test-binaries/integration-container-tun \; && \ - find /app/target/x86_64-unknown-linux-musl/release/deps -name 'integration_container_route-*' -type f ! -name '*.d' -exec cp {} /app/test-binaries/integration-container-route \; && \ - strip /app/test-binaries/* + mkdir -p /app/out && \ + cp /app/target/x86_64-unknown-linux-musl/release/h3llo /app/out/ && \ + strip /app/out/h3llo && \ + find /app/target/x86_64-unknown-linux-musl/release/deps -name 'integration_container_tun-*' -type f ! -name '*.d' -exec cp {} /app/out/integration-container-tun \; && \ + find /app/target/x86_64-unknown-linux-musl/release/deps -name 'integration_container_route-*' -type f ! -name '*.d' -exec cp {} /app/out/integration-container-route \; && \ + strip /app/out/* -# Stage 4: Runtime - Minimal Alpine production image +# Stage 3: Runtime - Minimal Alpine production image FROM alpine:3.21 AS runtime RUN apk add --no-cache ca-certificates -COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/h3llo /usr/local/bin/h3llo +COPY --from=builder /app/out/h3llo /usr/local/bin/h3llo RUN mkdir -p /etc/h3llo WORKDIR /etc/h3llo ENTRYPOINT ["/usr/local/bin/h3llo"] CMD ["-c", "/etc/h3llo/config.yaml"] -# Stage 5: Test - Adds diagnostic tools for integration tests +# Stage 3a: Test - Adds diagnostic tools for integration tests FROM runtime AS test RUN apk add --no-cache iproute2 iputils-ping iperf3 # Include pre-built test binaries for Container Test Pattern -COPY --from=builder /app/test-binaries/integration-container-tun /usr/local/bin/ -COPY --from=builder /app/test-binaries/integration-container-route /usr/local/bin/ +COPY --from=builder /app/out/integration-container-tun /usr/local/bin/ +COPY --from=builder /app/out/integration-container-route /usr/local/bin/ Step 2: Update CI workflow — Add
Code Draft - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
+ with:
+ keep-state: true
- name: Build Docker test image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: h3llo:test
target: test
# cache-from: type=gha
# cache-to: type=gha,mode=max
load: trueStep 3: Update
Code DraftPrerequisites section (lines 70-76): ### Prerequisites 1. Docker daemon running -2. Build the test image: +2. Docker Buildx installed (`docker buildx version` to verify) +3. Build the test image: ```bash - docker build --target test -t h3llo:test . + docker buildx build --target test -t h3llo:test --load . ``` + **Rebuild required**: The test image embeds compiled h3llo and test binaries. + You must rebuild after any change to `src/`, `tests/integration/container/`, + `Cargo.toml`, or `Cargo.lock`. TUN section (line 198): ```bash # Build test image with embedded binaries -docker build --target test -t h3llo:test . +docker buildx build --target test -t h3llo:test --load . # Run TUN integration tests cargo test --test integration -- tun --ignored --nocapture ``` Route section (line 219): ```bash # Build test image with embedded binaries -docker build --target test -t h3llo:test . +docker buildx build --target test -t h3llo:test --load . # Run route integration tests cargo test --test integration -- route --ignored --nocapture ``` Container Test Pattern description (line 167): -3. Test binaries are built into the Docker `test` image during `docker build` +3. Test binaries are built into the Docker `test` image during `docker buildx build` Step 4: Update
Code Drafteprintln!( - " docker build --target test -t {}:{} .", + " docker buildx build --target test -t {}:{} --load .", TEST_IMAGE, TEST_TAG ); Step 5: Update
Code Draft//! Run with: //! ```bash -//! docker build --target test -t h3llo:test . # build image with embedded binaries +//! docker buildx build --target test -t h3llo:test --load . # build image with embedded binaries //! cargo test --test integration -- tun --ignored --nocapture //! ``` panic!(
"Docker image {TEST_IMAGE}:{TEST_TAG} not found. Build with:\n \
- docker build --target test -t {TEST_IMAGE}:{TEST_TAG} ."
+ docker buildx build --target test -t {TEST_IMAGE}:{TEST_TAG} --load ."
);Step 6: Update
Code Draft//! Run with: //! ```bash -//! docker build --target test -t h3llo:test . # build image with embedded binaries +//! docker buildx build --target test -t h3llo:test --load . # build image with embedded binaries //! cargo test --test integration -- route --ignored --nocapture //! ``` panic!(
"Docker image {TEST_IMAGE}:{TEST_TAG} not found. Build with:\n \
- docker build --target test -t {TEST_IMAGE}:{TEST_TAG} ."
+ docker buildx build --target test -t {TEST_IMAGE}:{TEST_TAG} --load ."
);Success Criteria
Risks and Mitigations
ValidationCompatibility check: All selections are compatible.
User constraint applied: The commented-out Selection History
Refine History
Sources: Activity
MetadataMetadataAssigneesLabelsagentize:planIssues with implementation plans TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |