Diffinery

homeflare/celldpublic

celld/Dockerfile
46 lines · 2.0 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 final image depends on this stage, so a break in the engine's tests or
22# lints stops the build.
23FROM build AS test
24ARG TARGETARCH
25RUN rustup component add clippy
26# The ltx fault-injection oracle diffs databases with the sqlite3 CLI.
27RUN apt-get update && \
28 apt-get install -y --no-install-recommends sqlite3 && \
29 rm -rf /var/lib/apt/lists/*
30RUN --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
36FROM debian:bookworm-slim
37RUN apt-get update && \
38 apt-get install -y --no-install-recommends ca-certificates && \
39 rm -rf /var/lib/apt/lists/*
40ARG CELLD_COMMIT
41ARG CELLD_VERSION=unknown
42LABEL org.opencontainers.image.title="celld" \
43 org.opencontainers.image.revision="${CELLD_COMMIT}" \
44 org.opencontainers.image.version="${CELLD_VERSION}"
45COPY --from=test /out/celld /usr/local/bin/celld
46ENTRYPOINT ["/usr/local/bin/celld"]