-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
63 lines (51 loc) · 1.71 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
# Dockerfile for md-validator.
#
# Performed as a two-stage build so that we can use Maven to generate the application
# but not have it (and the things it downloads) clutter up the deployed image.
#
#
# Build the .jar file in a build container. Run this under the build platform
# even if we're generating an image for an emulated target platform.
#
FROM --platform=$BUILDPLATFORM maven:3.8.5-openjdk-17 AS builder
LABEL maintainer="Ian Young <[email protected]>"
WORKDIR /application
COPY pom.xml ./
COPY swagger swagger
COPY src src
RUN mvn --batch-mode \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
package
#
# Extract the layers.
#
RUN java -Djarmode=layertools \
-jar target/md-validator-0.1.0-SNAPSHOT.jar \
extract
#
# Build the deployable image.
#
FROM amazoncorretto:17 AS deploy
LABEL maintainer="Ian Young <[email protected]>"
#
# Copy the layers extracted from the JAR.
#
WORKDIR /application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
#
# At this point, we have:
#
# /application/org... containing the Spring Boot loader
# /application/META-INF containing the application metadata
# /application/BOOT-INF containing the application and its dependencies
# /application/BOOT-INF/classes contain the application classes and resources
#
# To customise, add layers modifying /application/BOOT-INF/classes...
#
EXPOSE 8080
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
HEALTHCHECK --interval=15s CMD ["/usr/bin/curl", "--silent", "http://localhost:8080/actuator/health"]