bin-select on cargo chef

This commit is contained in:
41666 2022-12-13 00:30:50 -05:00
parent 9365abc7f8
commit c483764b4b

View file

@ -1,5 +1,6 @@
# Step -1: Grab mold
FROM lukemathwalker/cargo-chef as rust-base
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends curl clang
ARG MOLD_VERSION=1.7.1
RUN curl -sSL https://github.com/rui314/mold/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-x86_64-linux.tar.gz | tar xzv && \
@ -10,21 +11,18 @@ ENV RUSTFLAGS="-C link-arg=-fuse-ld=/mold"
# Step 1: Compute a recipe file
FROM rust-base as planner
WORKDIR /app
RUN cargo install cargo-chef
ARG SERVICE
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef prepare --recipe-path recipe.json --bin ${SERVICE}
# Step 2: Cache project dependencies
FROM rust-base as cacher
WORKDIR /app
RUN cargo install cargo-chef
ARG SERVICE
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
RUN cargo chef cook --release --recipe-path recipe.json --bin ${SERVICE}
# Step 3: Build the binary
FROM rust-base as builder
WORKDIR /app
COPY . .
# Copy over the cached dependencies from above
COPY --from=cacher /app/target target