Image builds compile every dependency again on any Cargo.lock change #438

Closed
opened 2026-11-09 05:58:10 -08:00 by rays · 1 comment
Owner

Dockerfile builds the dependencies in one layer, which any change to Cargo.toml or Cargo.lock invalidates, so all 509 crates compile again in release, holding the builder's 6 GB cap for minutes (adding crates/tui did it on 2026-11-09). Dockerfile.directory has no dependency layer at all and compiles everything on every build. BuildKit cache mounts for cargo's registry and target/ would keep compiled crates between builds, so only what changed compiles.

Dockerfile builds the dependencies in one layer, which any change to Cargo.toml or Cargo.lock invalidates, so all 509 crates compile again in release, holding the builder's 6 GB cap for minutes (adding crates/tui did it on 2026-11-09). Dockerfile.directory has no dependency layer at all and compiles everything on every build. BuildKit cache mounts for cargo's registry and target/ would keep compiled crates between builds, so only what changed compiles.
rays added the enhancement label 2026-11-09 05:58:10 -08:00
Author
Owner

Fixed in 3a3900e: cargo's registry and target/ are BuildKit cache mounts in Dockerfile and Dockerfile.directory. Measured: a Cargo.toml change now compiles 3 crates in 52 s, where it compiled 405 in 170 s; the lowest MemAvailable was about the same (8.1 GB against 7.9), since the ipx crate itself is most of the peak. Both images built, pushed and checked with --version.

Fixed in 3a3900e: cargo's registry and target/ are BuildKit cache mounts in Dockerfile and Dockerfile.directory. Measured: a Cargo.toml change now compiles 3 crates in 52 s, where it compiled 405 in 170 s; the lowest MemAvailable was about the same (8.1 GB against 7.9), since the ipx crate itself is most of the peak. Both images built, pushed and checked with --version.
rays closed this issue 2026-11-09 06:05:15 -08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#438