LukeMathWalker / cargo-chef

A cargo-subcommand to speed up Rust Docker builds using Docker layer caching.
Apache License 2.0
1.79k stars 117 forks source link

Add `--bins` flag #238

Closed mladedav closed 8 months ago

mladedav commented 1 year ago

We have a workspace with several projects, each containing one binary.

We would like to have a single caching layer where all dependencies for all binaries are already precompiled and then compile only the binaries themselves so that there aren't multiple cache docker layers.

Another thing I have noticed is cargo chef accepts only one --bin argument while cargo build et al. allow for multiple binaries to be specified. Either of those would help in our situation if you have reservations about either.

Originally I wanted to do just simple cargo chef cook and cargo build -p package, but it turns out this leads to several recompilations, seemingly because of feature sets and possibly other issues. cargo chef cook followed by cargo build --bin package is somewhat better, but there were still a few recompilations (although I didn't check closer why yet). The only way currently available I have found is cargo chef cook --all-targets but that of course also compiles a lot of stuff we do not want.

thomaseizinger commented 1 year ago

I am running into the same issue and tried to use --all-targets but that didn't really help at all. I've contemplated to just invoke cargo chef cook multiple times, one for each binary. Until #241 is being released, would that be equivalent?