-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (29 loc) · 1.03 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Use an official OpenJDK runtime as a parent image
FROM maven:3.9.8-sapmachine-22 as builder
# Set the working directory to /app
WORKDIR /app
# Copy POM file
COPY pom.xml .
# Install dependencies
RUN mvn -ntp dependency:go-offline
# Copy the source code
COPY src src
# Package the application
RUN mvn -ntp package -DskipTests
# Use an official OpenJDK runtime as a parent image
FROM openjdk:22-jdk-slim as layers
# The name of the application's jar file
ARG APP_NAME
# Bring in the JAR file from the builder stage
COPY --from=builder /app/target/${APP_NAME}.jar .
# Extract the layers
RUN java -Djarmode=layertools -jar ${APP_NAME}.jar extract
# Use an official OpenJDK runtime as a parent image
FROM openjdk:22-jdk-slim as runtime
# Bringing in the extracted layers from the layers stage
COPY --from=layers dependencies/ .
COPY --from=layers snapshot-dependencies/ .
COPY --from=layers spring-boot-loader/ .
COPY --from=layers application/ .
# Run the extracted layers
CMD ["java", "org.springframework.boot.loader.launch.JarLauncher"]