Skip to content

Commit 07c8287

Browse files
committed
Fixing Maven Cache issues on Dockerfile build
1 parent 90e9989 commit 07c8287

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ build/
3333
.vscode/
3434

3535
.env
36+
37+
.cache/.m2/repository

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ COPY .mvn .mvn
1313
COPY pom.xml .
1414
COPY src ./src
1515

16-
RUN mvn clean install -DskipTests --settings .mvn/settings.xml
16+
# Install dependencies first (this layer will be cached)
17+
RUN --mount=type=cache,target=/root/.m2 \
18+
mvn dependency:go-offline --settings .mvn/settings.xml
19+
20+
# Build the application
21+
RUN --mount=type=cache,target=/root/.m2 \
22+
mvn clean install -DskipTests --settings .mvn/settings.xml
1723

1824
# Run stage
1925
FROM eclipse-temurin:21-jre-jammy

0 commit comments

Comments
 (0)