From 4f2b1bb3816eed085e44815ccbf35256365e2560 Mon Sep 17 00:00:00 2001 From: Ludy Date: Thu, 20 Aug 2026 18:56:59 +0000 Subject: [PATCH] Cache Docker dependency downloads in embedded images (#7535) # Description of Changes Adds Docker BuildKit syntax and shared Gradle/npm cache mounts to the fat and ultra-lite embedded Dockerfiles. This reduces repeated dependency downloads during rebuilds and speeds up image builds without changing runtime behavior. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details. --- .github/workflows/docker-compose-tests.yml | 2 +- docker/embedded/Dockerfile.fat | 9 +++++++-- docker/embedded/Dockerfile.ultra-lite | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-compose-tests.yml b/.github/workflows/docker-compose-tests.yml index 439d4240b2..32195ac66e 100644 --- a/.github/workflows/docker-compose-tests.yml +++ b/.github/workflows/docker-compose-tests.yml @@ -66,7 +66,7 @@ jobs: - name: Install Docker Compose run: | - sudo curl -SL "https://github.com/docker/compose/releases/download/v2.39.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo curl -SL "https://github.com/docker/compose/releases/download/v5.4.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose - name: Install uv diff --git a/docker/embedded/Dockerfile.fat b/docker/embedded/Dockerfile.fat index 5e6ef418f6..bdaa005517 100644 --- a/docker/embedded/Dockerfile.fat +++ b/docker/embedded/Dockerfile.fat @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # Stirling-PDF - Fat version (embedded frontend) # Extra fonts for air-gapped environments # Uses pre-built base image for fast builds @@ -38,7 +40,8 @@ COPY app/common/build.gradle app/common/ COPY app/proprietary/build.gradle app/proprietary/ # Use system gradle instead of gradlew to avoid SSL issues downloading gradle distribution on emulated arm64 -RUN gradle dependencies --no-daemon || true +RUN --mount=type=cache,id=stirling-pdf-gradle-cache,target=/home/gradle/.gradle,sharing=locked \ + gradle dependencies --no-daemon || true COPY . . @@ -46,7 +49,9 @@ COPY . . ARG BUILD_PORTAL=false # Bundle only the JPDFium native for this image's target arch. ARG TARGETARCH -RUN JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo linux-x64)" && \ +RUN --mount=type=cache,id=stirling-pdf-npm-cache,target=/root/.npm,sharing=locked \ + --mount=type=cache,id=stirling-pdf-gradle-cache,target=/home/gradle/.gradle,sharing=locked \ + JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo linux-x64)" && \ DISABLE_ADDITIONAL_FEATURES=false \ gradle clean build \ -PbuildWithFrontend=true \ diff --git a/docker/embedded/Dockerfile.ultra-lite b/docker/embedded/Dockerfile.ultra-lite index e320c3e0a7..a94f9eeeda 100644 --- a/docker/embedded/Dockerfile.ultra-lite +++ b/docker/embedded/Dockerfile.ultra-lite @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # Stirling-PDF Dockerfile - Ultra-lite version with embedded frontend # Single JAR contains both frontend and backend with minimal dependencies @@ -36,7 +38,8 @@ ENV JDK_JAVA_OPTIONS="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNN --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" -RUN ./gradlew dependencies --no-daemon || true +RUN --mount=type=cache,id=stirling-pdf-gradle-cache,target=/home/gradle/.gradle,sharing=locked \ + ./gradlew dependencies --no-daemon || true # Copy entire project COPY . . @@ -46,7 +49,9 @@ COPY . . ARG BUILD_PORTAL=false # Bundle only the JPDFium native for this image's target arch. ARG TARGETARCH -RUN JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo linux-x64)" && \ +RUN --mount=type=cache,id=stirling-pdf-npm-cache,target=/root/.npm,sharing=locked \ + --mount=type=cache,id=stirling-pdf-gradle-cache,target=/home/gradle/.gradle,sharing=locked \ + JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo linux-x64)" && \ DISABLE_ADDITIONAL_FEATURES=true \ ./gradlew clean build \ -PbuildWithFrontend=true \