From 1d50883dbd20856894a7287d54608a249607260f Mon Sep 17 00:00:00 2001 From: Gabi Date: Mon, 26 Jun 2023 16:46:20 -0300 Subject: [PATCH] rust: fix dockerfile for building multiple images in parallel (#1699) When using `docker compose build` or any other way of building docker images in parallel the way the cache was working with the rust's Dockerfile made the caches between images overlap and corrupt each other. We add a `locked` which prevents multiple writers to the same cache to fix this behaviour. --- rust/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Dockerfile b/rust/Dockerfile index 0c60bd409..61b26c3e8 100644 --- a/rust/Dockerfile +++ b/rust/Dockerfile @@ -3,8 +3,8 @@ ARG PACKAGE WORKDIR /build/ COPY . ./ RUN --mount=type=cache,target=./target \ - --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=/usr/local/rustup \ + --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \ + --mount=type=cache,target=/usr/local/rustup,sharing=locked \ apt update && apt install -y musl-tools && \ cargo build -p $PACKAGE --release --target x86_64-unknown-linux-musl