You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had run into an issue where chef wasn't caching properly because I'm using a workspace with multiple crates.
A minimal Dockerfile example could be:
ARG PROFILE=release
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release -p package
# alternative: cargo install --path package
Here, the package chosen may change the feature selection on some dependencies, which can cause a large recompile. Chef will have built for all packages, and so the dependencies will use the maximal feature set, while the build -p package may choose a smaller feature set for some dependencies and recompile a large amount of code.
In my particular case, I have a single cargo workspace and Dockerfile where I am building multiple containers from different crates.
The options for cargo chef in a workspace are either:
chef for all packages, build for all packages
chef per-package, build per-package
alternative: chef fetch for all packages, chef cook per-package, build per-package
I can see an outstanding issue (#180) that hints at usage of a workspace with multiple crates and may be suffering the same fate.
Proposal
Add a cargo chef fetch or cargo chef cook --download-only to download dependencies, but avoid compiling them. I'm ignorant to how cargo chef is implemented, but the cargo fetch command could hopefully provide the functionality?
Documentation
It might be worth adding a point about workspaces and crates depending on different features, it took me a few hours to figure out what was happening! Perhaps as a troubleshooting guide, or some form of "here's what's recommended for workspaces with multiple crates" section in the README?
The text was updated successfully, but these errors were encountered:
Context
I had run into an issue where chef wasn't caching properly because I'm using a workspace with multiple crates.
A minimal Dockerfile example could be:
Here, the package chosen may change the feature selection on some dependencies, which can cause a large recompile. Chef will have built for all packages, and so the dependencies will use the maximal feature set, while the
build -p package
may choose a smaller feature set for some dependencies and recompile a large amount of code.In my particular case, I have a single cargo workspace and Dockerfile where I am building multiple containers from different crates.
The options for cargo chef in a workspace are either:
I can see an outstanding issue (#180) that hints at usage of a workspace with multiple crates and may be suffering the same fate.
Proposal
Add a
cargo chef fetch
orcargo chef cook --download-only
to download dependencies, but avoid compiling them. I'm ignorant to howcargo chef
is implemented, but thecargo fetch
command could hopefully provide the functionality?Documentation
It might be worth adding a point about workspaces and crates depending on different features, it took me a few hours to figure out what was happening! Perhaps as a troubleshooting guide, or some form of "here's what's recommended for workspaces with multiple crates" section in the README?
The text was updated successfully, but these errors were encountered: