Skip to content

cargo chef doesn't support examples properly #322

@AnomalRoil

Description

@AnomalRoil

I'm building some example code using:

FROM chef AS planner

COPY . .
RUN cargo chef prepare --recipe-path recipe.json --bin my-example

FROM chef AS builder

COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY . .
RUN cargo build --release -p my-example --example my-example

And sadly it seems the dependencies that are being compiled by the cook step are not the same ones as the ones used by cargo build --example my-example, and so it's rebuilding it all.

I've found that cook supports --examples, but it seems sometimes it's not always building all the required dependencies for my example binaries, it allows to not rebuild all the dependencies, however, only a few.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions