Skip to content

Commit

Permalink
build: Simplify Dockerfile by removing cache mounts from cargo commands
Browse files Browse the repository at this point in the history
Those are only valid for buildx, not needed for kaniko.

Signed-off-by: Eden Reich <[email protected]>
  • Loading branch information
edenreich committed Feb 26, 2025
1 parent 3abdba0 commit 72a5c91
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ ENV CC=clang \
PATH="/root/.cargo/bin:${PATH}"

COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/app/target \
cargo chef cook --release --target ${TARGET_ARCH} --recipe-path recipe.json
RUN cargo chef cook --release --target ${TARGET_ARCH} --recipe-path recipe.json

FROM cacher AS builder
ARG TARGET_ARCH
COPY src ./src
COPY --from=cacher /app/target /app/target
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/app/target \
cargo build --release --jobs $(nproc) --target ${TARGET_ARCH}
RUN cargo build --release --jobs $(nproc) --target ${TARGET_ARCH}

FROM gcr.io/distroless/static:nonroot AS minimal
ARG TARGET_ARCH
Expand Down

0 comments on commit 72a5c91

Please sign in to comment.