Diffinery

homeflare/celldpublic

celld/Dockerfile
43 lines · 1.8 KBRaw History
1# syntax=docker/dockerfile:1.7
2
3ARG RUST_VERSION=1.97.1
4ARG CELLD_COMMIT=unknown
5
6FROM rust:${RUST_VERSION}-bookworm AS build
7ARG 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.
10ARG CELLD_PROFILE=release
11WORKDIR /src
12COPY Cargo.toml Cargo.lock ./
13COPY crates ./crates
14RUN --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.
24FROM build AS test
25ARG TARGETARCH
26RUN rustup component add clippy
27RUN --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
33FROM debian:bookworm-slim
34RUN apt-get update && \
35 apt-get install -y --no-install-recommends ca-certificates && \
36 rm -rf /var/lib/apt/lists/*
37ARG CELLD_COMMIT
38ARG CELLD_VERSION=unknown
39LABEL org.opencontainers.image.title="celld" \
40 org.opencontainers.image.revision="${CELLD_COMMIT}" \
41 org.opencontainers.image.version="${CELLD_VERSION}"
42COPY --from=build /out/celld /usr/local/bin/celld
43ENTRYPOINT ["/usr/local/bin/celld"]