Give each Docker build stage its own cargo registry cache
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:
1 parent
eb96e6d8c2
commit
be3b995bb8
1 file changed
+5
-2
+5
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user