-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-v2
21 lines (18 loc) · 946 Bytes
/
Dockerfile-v2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
FROM eclipse-temurin:17 AS builder
WORKDIR workspace
#the below location needs to be different depending on the build tool. Example, maven has different location.
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
#extract layers using layertools jar mode.
RUN java -Djarmode=layertools -jar app.jar extract
FROM eclipse-temurin:17
WORKDIR workspace
#copy jar layers from the extracted to this workspace
COPY --from=builder workspace/dependencies/ ./
COPY --from=builder workspace/spring-boot-loader/ ./
COPY --from=builder workspace/snapshot-dependencies/ ./
COPY --from=builder workspace/application/ ./
#The Spring Boot fat JarLauncher is extracted from the JAR into the image,
# so it can be used to start the application without hard-coding the main application class.
ENTRYPOINT ["java","-Xmx1g","org.springframework.boot.loader.JarLauncher"]
#More details on the above are here https://spring.io/guides/topicals/spring-boot-docker/