diff --git a/Dockerfile b/Dockerfile index c665d4a..ddbb0d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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