diff mbox series

[v6,07/12] docker: Use cache mounts for apt

Message ID 20241127172247.1488685-8-trini@konsulko.com
State Accepted
Commit 191e1454711717bfee10cc76c015a083208b9609
Delegated to: Tom Rini
Headers show
Series CI: Set up for an arm64 runner | expand

Commit Message

Tom Rini Nov. 27, 2024, 5:17 p.m. UTC
Instead of deleting /var/lib/apt/lists after each relevant RUN line, use
a cache mount as is the current best practices.

Signed-off-by: Tom Rini <trini@konsulko.com>
---
Changes in v6:
- New patch
---
 tools/docker/Dockerfile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Simon Glass Nov. 28, 2024, 3:45 p.m. UTC | #1
On Wed, 27 Nov 2024 at 10:23, Tom Rini <trini@konsulko.com> wrote:
>
> Instead of deleting /var/lib/apt/lists after each relevant RUN line, use
> a cache mount as is the current best practices.
>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
> Changes in v6:
> - New patch
> ---
>  tools/docker/Dockerfile | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 90c90bd05f0b..bc8d1ebbb1e8 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -10,7 +10,9 @@  LABEL org.opencontainers.image.description=" This image is for building U-Boot i
 ENV DEBIAN_FRONTEND=noninteractive
 
 # Add LLVM repository
-RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
+RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
+    --mount=type=cache,target=/var/lib/apt,sharing=locked \
+    apt-get update && apt-get install -y gnupg2 wget xz-utils
 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
 RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list
 
@@ -33,7 +35,9 @@  RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_
 RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz
 
 # Update and install things from apt now
-RUN apt-get update && apt-get install -y \
+RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
+    --mount=type=cache,target=/var/lib/apt,sharing=locked \
+    apt-get update && apt-get install -y \
 	automake \
 	autopoint \
 	bc \
@@ -118,8 +122,7 @@  RUN apt-get update && apt-get install -y \
 	vboot-utils \
 	xilinx-bootgen \
 	xxd \
-	zip \
-	&& rm -rf /var/lib/apt/lists/*
+	zip
 
 # Make kernels readable for libguestfs tools to work correctly
 RUN chmod +r /boot/vmlinu*