celld/Dockerfile
| 1 | # syntax=docker/dockerfile:1.7 |
| 2 | |
| 3 | ARG RUST_VERSION=1.97.1 |
| 4 | ARG CELLD_COMMIT=unknown |
| 5 | |
| 6 | FROM rust:${RUST_VERSION}-bookworm AS build |
| 7 | ARG TARGETARCH |
| 8 | # `release` for shipped artifacts; a fast-loop caller passes `lab` to skip |
| 9 | # the fat-LTO relink and keep incremental state in the target cache. |
| 10 | ARG CELLD_PROFILE=release |
| 11 | WORKDIR /src |
| 12 | COPY Cargo.toml Cargo.lock ./ |
| 13 | COPY crates ./crates |
| 14 | RUN --mount=type=cache,id=celld-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ |
| 15 | --mount=type=cache,id=celld-cargo-git,target=/usr/local/cargo/git,sharing=locked \ |
| 16 | --mount=type=cache,id=celld-target-${TARGETARCH},target=/src/target,sharing=locked \ |
| 17 | mkdir -p /out && \ |
| 18 | cargo build --profile "${CELLD_PROFILE}" --locked -p celld && \ |
| 19 | install -m 755 "target/${CELLD_PROFILE}/celld" /out/celld |
| 20 | |
| 21 | # The release workflow builds this stage on every candidate push, so a |
| 22 | # break in the engine's own tests or lints stops a release before any |
| 23 | # artifact is drafted. |
| 24 | FROM build AS test |
| 25 | ARG TARGETARCH |
| 26 | RUN rustup component add clippy |
| 27 | RUN --mount=type=cache,id=celld-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ |
| 28 | --mount=type=cache,id=celld-cargo-git,target=/usr/local/cargo/git,sharing=locked \ |
| 29 | --mount=type=cache,id=celld-target-${TARGETARCH},target=/src/target,sharing=locked \ |
| 30 | cargo test --release --locked && \ |
| 31 | cargo clippy --release --all-targets --locked -- -D warnings |
| 32 | |
| 33 | FROM debian:bookworm-slim |
| 34 | RUN apt-get update && \ |
| 35 | apt-get install -y --no-install-recommends ca-certificates && \ |
| 36 | rm -rf /var/lib/apt/lists/* |
| 37 | ARG CELLD_COMMIT |
| 38 | ARG CELLD_VERSION=unknown |
| 39 | LABEL org.opencontainers.image.title="celld" \ |
| 40 | org.opencontainers.image.revision="${CELLD_COMMIT}" \ |
| 41 | org.opencontainers.image.version="${CELLD_VERSION}" |
| 42 | COPY --from=build /out/celld /usr/local/bin/celld |
| 43 | ENTRYPOINT ["/usr/local/bin/celld"] |