-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathDockerfile.chef
More file actions
40 lines (30 loc) · 1.15 KB
/
Dockerfile.chef
File metadata and controls
40 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FROM rust:1.93-bookworm AS chef
RUN cargo install cargo-chef sccache
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
ARG TARGETARCH
ARG RUST_PROFILE=profiling
ARG RUST_FEATURES="asm-keccak,jemalloc,otlp"
ARG EXTRA_RUSTFLAGS=""
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
pkg-config \
libssl-dev \
build-essential \
clang \
libclang-dev \
mold \
&& rm -rf /var/lib/apt/lists/*
ENV RUSTC_WRAPPER=sccache \
SCCACHE_DIR=/sccache \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked,id=cargo-registry-${TARGETARCH} \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked,id=cargo-git-${TARGETARCH} \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked,id=sccache-${TARGETARCH} \
RUSTFLAGS="-C link-arg=-fuse-ld=mold ${EXTRA_RUSTFLAGS}" \
cargo chef cook --profile ${RUST_PROFILE} --features "${RUST_FEATURES}" --recipe-path recipe.json