8
8
#
9
9
# Build the .jar file in a build container.
10
10
#
11
- FROM maven:3.5.3-jdk-11 AS build-jar
11
+ FROM maven:3.5.3-jdk-11 AS builder
12
12
MAINTAINER Ian Young <
[email protected] >
13
13
14
- WORKDIR /user
14
+ WORKDIR /application
15
15
COPY pom.xml ./
16
16
COPY swagger swagger
17
17
COPY src src
@@ -20,14 +20,39 @@ RUN mvn --batch-mode \
20
20
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
21
21
package
22
22
23
+ #
24
+ # Extract the layers.
25
+ #
26
+ RUN java -Djarmode=layertools \
27
+ -jar target/md-validator-0.1.0-SNAPSHOT.jar \
28
+ extract
29
+
23
30
#
24
31
# Build the deployable image.
25
32
#
26
33
FROM amazoncorretto:11
27
34
MAINTAINER Ian Young <
[email protected] >
28
35
29
- WORKDIR /user
30
- COPY --from=build-jar /user/target/md-validator-0.1.0-SNAPSHOT.jar .
36
+ #
37
+ # Copy the layers extracted from the JAR.
38
+ #
39
+ WORKDIR /application
40
+ COPY --from=builder application/dependencies/ ./
41
+ COPY --from=builder application/spring-boot-loader/ ./
42
+ COPY --from=builder application/snapshot-dependencies/ ./
43
+ COPY --from=builder application/application/ ./
44
+
45
+ #
46
+ # At this point, we have:
47
+ #
48
+ # /application/org... containing the Spring Boot loader
49
+ # /application/META-INF containing the application metadata
50
+ # /application/BOOT-INF containing the application and its dependencies
51
+ # /application/BOOT-INF/classes contain the application classes and resources
52
+ #
53
+ # To customise, add layers modifying /application/BOOT-INF/classes...
54
+ #
31
55
32
56
EXPOSE 8080
33
- CMD ["java" , "-jar" , "md-validator-0.1.0-SNAPSHOT.jar" ]
57
+
58
+ ENTRYPOINT ["java" , "org.springframework.boot.loader.JarLauncher" ]
0 commit comments