celld/Dockerfile
| 1 | # syntax=docker/dockerfile:1.7 |
| 2 | |
| 3 | ARG RUST_VERSION=1.98.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 final image depends on this stage, so a break in the engine's tests or |
| 22 | # lints stops the build. |
| 23 | FROM build AS test |
| 24 | ARG TARGETARCH |
| 25 | RUN rustup component add clippy |
| 26 | # The ltx fault-injection oracle diffs databases with the sqlite3 CLI. |
| 27 | RUN apt-get update && \ |
| 28 | apt-get install -y --no-install-recommends sqlite3 && \ |
| 29 | rm -rf /var/lib/apt/lists/* |
| 30 | RUN --mount=type=cache,id=celld-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ |
| 31 | --mount=type=cache,id=celld-cargo-git,target=/usr/local/cargo/git,sharing=locked \ |
| 32 | --mount=type=cache,id=celld-target-${TARGETARCH},target=/src/target,sharing=locked \ |
| 33 | cargo test --profile "${CELLD_PROFILE}" --locked && \ |
| 34 | cargo clippy --profile "${CELLD_PROFILE}" --all-targets --locked -- -D warnings |
| 35 | |
| 36 | FROM debian:bookworm-slim |
| 37 | RUN apt-get update && \ |
| 38 | apt-get install -y --no-install-recommends ca-certificates && \ |
| 39 | rm -rf /var/lib/apt/lists/* |
| 40 | ARG CELLD_COMMIT |
| 41 | ARG CELLD_VERSION=unknown |
| 42 | LABEL org.opencontainers.image.title="celld" \ |
| 43 | org.opencontainers.image.revision="${CELLD_COMMIT}" \ |
| 44 | org.opencontainers.image.version="${CELLD_VERSION}" |
| 45 | COPY LICENSE NOTICE /usr/share/doc/celld/ |
| 46 | COPY --from=test /out/celld /usr/local/bin/celld |
| 47 | ENTRYPOINT ["/usr/local/bin/celld"] |