Containerfile: add cargo-chef for dependency-layer caching in podman build #3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The two-stage Containerfile copies
Cargo.toml+src/together then runscargo build --release— every source change invalidates the build layer → full dependency recompile every deploy.Fix: adopt the cargo-chef planner/cache/cooker pattern:
plannerstage:cargo chef prepare --recipe-path recipe.jsonfrom Cargo.toml/Cargo.lockcachestage:cargo chef cook --release --recipe-path recipe.json— dep compilation, cached as a layerbuilderstage: copy recipe + sources,cargo build --release— only recompiles app code unless deps changeEffect: dep changes only recompile when Cargo.toml/Cargo.lock actually change; day-to-day source-only pushes reuse the cached dep layer (seconds vs minutes).
This is app-level (this Containerfile) but the archetype comes from the ditc scaffold — the template should adopt cargo-chef too so new apps inherit it (cross-reference: dit-client template ticket).
Superseded by #11 (migrate to dynamic-nix). dynamic-nix has no Containerfile, so cargo-chef (#3) and sccache (#2) become throwaway work — nix build derivation caching replaces both. Do not start these until #11 is decided. If #11 does not proceed, these remain valid.
Superseded by #11 (migrate to dynamic-nix). dynamic-nix has no Containerfile, so cargo-chef (#3) and sccache (#2) become throwaway work — nix build derivation caching replaces both. Do not start these until #11 is decided. If #11 does not proceed, these remain valid.