Our crates use unpacked debuginfo which are not copied to recipe.json which makes cargo build rebuild everything, making the cache step useless.
Reproduction
Setup a project:
cargo new --lib dummy
cd dummy
cargo add tokio --features full
cat << EOF >> Cargo.toml
[profile.dev]
split-debuginfo = "unpacked"
EOF
Create a Dockerfile
FROM rust:slim-bullseye AS chef
RUN cargo install cargo-chef
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json
COPY . .
# Rebuilds everything from scratch
RUN cargo build
Build it: docker build -t foo .
Workaround
I didn't find a suitable workaround. It would be needed to fix the generated Cargo.toml before the project is built during cargo chef cook. It might be possibl to manually fix the recipe.json file.
Context
This may also happen with other options. This is also an issue for workspace-level Cargo.toml.
Problem
Our crates use unpacked debuginfo which are not copied to
recipe.json
which makescargo build
rebuild everything, making the cache step useless.Reproduction
Setup a project:
Create a Dockerfile
Build it:
docker build -t foo .
Workaround
I didn't find a suitable workaround. It would be needed to fix the generated
Cargo.toml
before the project is built duringcargo chef cook
. It might be possibl to manually fix therecipe.json
file.Context
This may also happen with other options. This is also an issue for workspace-level
Cargo.toml
.