From 4ba7f01ba48f9b86a655f19a7d1bf744711d3b44 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 11 Jun 2026 14:20:16 +0200 Subject: [PATCH] [git-bridge] Cache maven artifacts in base layer (#34424) * [git-bridge] Cache maven artifacts in base layer Adds a Dockerfile stage to resolve dependencies in the `base` layer, which is cached for production and e2e/dev builds. GitOrigin-RevId: 0830a3be0c02e5e09e370cf64cdccc30ebf42d7a --- services/git-bridge/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/git-bridge/Dockerfile b/services/git-bridge/Dockerfile index e1309125a7..ab139ec7f9 100644 --- a/services/git-bridge/Dockerfile +++ b/services/git-bridge/Dockerfile @@ -16,6 +16,21 @@ RUN chmod +x /opt/envsubst RUN useradd --create-home node +ENV MAVEN_OPTS="-Dmaven.repo.local=/home/node/repository" + +# Pre-resolve Maven dependencies and plugins into the base image to limit +# downstream `mvn` invocations hitting Maven Central on every CI build. +# Uses a stub source and test, since `dependency:go-offline` and `dependency:resolve-plugins` +# miss lazy-loaded plugins (surefire, maven-assembly, etc.) +COPY pom.xml /tmp/warmup/pom.xml +RUN mkdir -p /tmp/warmup/src/main/java/stub /tmp/warmup/src/test/java/stub \ + && echo 'package stub; public class Stub {}' > /tmp/warmup/src/main/java/stub/Stub.java \ + && echo 'package stub; public class StubTest { @org.junit.Test public void noop() {} }' \ + > /tmp/warmup/src/test/java/stub/StubTest.java \ +&& mvn -B --no-transfer-progress -f /tmp/warmup/pom.xml clean package \ +&& chown -R node:node /home/node/repository \ +&& rm -rf /tmp/warmup + FROM base AS builder COPY . /app