perf: add BuildKit cache mounts for Maven and npm in Docker builds
Maven .m2 and npm caches persist across --no-cache builds, avoiding full dependency re-downloads on every CI run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend
|
||||
ARG REGISTRY_TOKEN
|
||||
WORKDIR /ui
|
||||
COPY ui/package.json ui/package-lock.json ui/.npmrc ./
|
||||
RUN echo "//gitea.siegeln.net/api/packages/cameleer/npm/:_authToken=${REGISTRY_TOKEN}" >> .npmrc && npm ci
|
||||
RUN --mount=type=cache,target=/root/.npm echo "//gitea.siegeln.net/api/packages/cameleer/npm/:_authToken=${REGISTRY_TOKEN}" >> .npmrc && npm ci
|
||||
COPY ui/ .
|
||||
RUN npm run build
|
||||
|
||||
@@ -14,11 +14,11 @@ FROM --platform=$BUILDPLATFORM eclipse-temurin:21-jdk-alpine AS build
|
||||
WORKDIR /build
|
||||
COPY .mvn/ .mvn/
|
||||
COPY mvnw pom.xml ./
|
||||
# Cache deps — only re-downloaded when POM changes
|
||||
RUN ./mvnw dependency:go-offline -B || true
|
||||
# Cache deps — BuildKit cache mount persists across --no-cache builds
|
||||
RUN --mount=type=cache,target=/root/.m2/repository ./mvnw dependency:go-offline -B || true
|
||||
COPY src/ src/
|
||||
COPY --from=frontend /ui/dist/ src/main/resources/static/
|
||||
RUN ./mvnw package -DskipTests -B
|
||||
RUN --mount=type=cache,target=/root/.m2/repository ./mvnw package -DskipTests -B
|
||||
|
||||
# Runtime: target platform (amd64)
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
|
||||
ARG REGISTRY_TOKEN
|
||||
WORKDIR /ui
|
||||
COPY package.json package-lock.json .npmrc ./
|
||||
RUN echo "//gitea.siegeln.net/api/packages/cameleer/npm/:_authToken=${REGISTRY_TOKEN}" >> .npmrc && npm ci
|
||||
RUN --mount=type=cache,target=/root/.npm echo "//gitea.siegeln.net/api/packages/cameleer/npm/:_authToken=${REGISTRY_TOKEN}" >> .npmrc && npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
|
||||
Reference in New Issue
Block a user