perf(dev): speed up dev-web image builds with target cache mount and higher job cap #458
Loading…
Reference in a new issue
No description provided.
Delete branch "perf/dev-web-build-speed"
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?
Why
just dev-web/dev-web-saasbuild the production multi-stage image, and local iteration was slow for two reasons.CARGO_BUILD_JOBS=2. That cap exists so the desktop and OCI builds can share one CI runner, but a local dev build runs one image at a time on a many-core host, so it just throttled the slow release compile to 2 jobs.lets-chat-servercrate in release mode, because nothing carried the releasetargetdir across--buildruns. cargo-chef caches dependencies but not the app crate.What
targetdir, keyed byBUILD_MODEso standalone and saas keep separate caches and never relink against each other. On a cold cache (every CI build; the first local build) it is seeded from the cargo-chef-cooked target withcp -ato preserve mtimes and keep dependency fingerprints valid; warm local rebuilds skip the copy and compile only changed crates. The cargo registry stays on the existing layer-cachedCOPYand is intentionally not cache-mounted (a registry cache mount would shadow that COPY and force a cold re-download).CARGO_BUILD_JOBS=N just dev-web. The Dockerfile default of 2 is unchanged, so CI behavior is untouched.Tradeoff
On a cold cache the seed copies the cooked target once (
cp -a). In CI, where the cache mount is not persisted, that is a small one-time copy per build instead of the prior layer COPY; the warm-rebuild win is local.Test
docker compose --file compose.dev-web.yml configand the saas variant both resolveCARGO_BUILD_JOBSto 16 and honor an override.docker build --checkonci-build/Dockerfile.weblints clean (cache-mount syntax and theBUILD_MODE-keyed id accepted).🤖 Generated with Claude Code