Give each Docker build stage its own cargo registry cache
Check / check (push) Successful in 1m3s
Check / guardrails (push) Successful in 1m11s
Check / bundle (push) Successful in 1m1s
Image / image (push) Successful in 2m16s

The web and server stages build in parallel and shared one registry cache mount. Cargo's lock on the registry lives in CARGO_HOME, outside the mount, so both stages could unpack the same crate at once; the image job failed twice on "File exists" (heck, then futures-task) after the rustls update.
This commit is contained in:
connor committed 2026-10-20 13:57:31 -04:00
1 parent eb96e6d8c2
commit be3b995bb8
1 file changed
+5 -2
+5 -2
View File
@@ -53,7 +53,10 @@ RUN npm ci
COPY . .
WORKDIR /app/crates/runway-web
RUN --mount=type=cache,target=/usr/local/cargo/registry \
# Each stage has its own registry cache. The two stages build at the same time,
# and cargo's lock on the registry is in CARGO_HOME, outside the mount, so a
# shared one let both unpack the same crate at once and fail on "File exists".
RUN --mount=type=cache,id=cargo-registry-web,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
trunk build --release
@@ -67,7 +70,7 @@ COPY . .
# of the layer: whatever is written there is gone by the time the next stage
# looks. This is also why there is no dummy-source dance -- the cache does what
# that trick was inventing.
RUN --mount=type=cache,target=/usr/local/cargo/registry \
RUN --mount=type=cache,id=cargo-registry-server,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release --locked -p runway-server \
&& cp target/release/runway-server /runway-server