-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
66 lines (54 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
64
65
66
#
# Dockerfile for mdq-server.
#
# 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 <ian@iay.org.uk>"
WORKDIR /application
COPY pom.xml ./
COPY src src
#
# Maven configuration from the host, including an access token
# for the ukf/packages registry on GitHub.
#
COPY m2 /root/.m2
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/mdq-server-0.1.0-SNAPSHOT.jar \
extract
#
# Build the deployable image.
#
FROM amazoncorretto:17 as deploy
LABEL maintainer="Ian Young <ian@iay.org.uk>"
#
# 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"]