From d544e11a205b4ea02a02d83c905e74f881d65b37 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 3 Jun 2025 15:04:38 +0200 Subject: [PATCH] Use pip build cache from inside Dockerfile (#3228) --- Dockerfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34e9703f..57317389 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,24 @@ WORKDIR /install COPY requirements.txt /requirements.txt -# --extra-index-url https://www.piwheels.org/simple is for cryptography module to be prebuilt (or rustc etc needs to be installed) -RUN pip install --extra-index-url https://www.piwheels.org/simple --target=/dependencies -r /requirements.txt +# Use cache mounts and multiple wheel sources for faster ARM builds +ENV PIP_CACHE_DIR=/tmp/pip-cache +RUN --mount=type=cache,target=/tmp/pip-cache \ + pip install \ + --extra-index-url https://www.piwheels.org/simple \ + --extra-index-url https://pypi.anaconda.org/ARM-software/simple \ + --cache-dir=/tmp/pip-cache \ + --target=/dependencies \ + -r /requirements.txt # Playwright is an alternative to Selenium # Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing # https://github.com/dgtlmoon/changedetection.io/pull/1067 also musl/alpine (not supported) -RUN pip install --target=/dependencies playwright~=1.48.0 \ +RUN --mount=type=cache,target=/tmp/pip-cache \ + pip install \ + --cache-dir=/tmp/pip-cache \ + --target=/dependencies \ + playwright~=1.48.0 \ || echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled." # Final image stage