-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_OLD_1
52 lines (40 loc) · 1.24 KB
/
Dockerfile_OLD_1
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
# First stage, build the custom JRE
FROM eclipse-temurin:21-jdk-alpine AS jre-builder
COPY src /app/src
COPY pom.xml /app
WORKDIR /app
ENV MAVEN_VERSION 3.5.4
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH
RUN apk update && \
apk add --no-cache tar binutils maven
RUN mvn clean package -DskipTests -U \
&& rm -rf /root/.m2 \
&& rm -rf /app/src
RUN jar xvf target/QualityLabPro-0.8.jar
RUN jdeps --ignore-missing-deps -q \
--recursive \
--multi-release 21 \
--print-module-deps \
--class-path 'BOOT-INF/lib/*' \
target/QualityLabPro-0.8.jar > modules.txt
# Build small JRE image
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules $(cat modules.txt) \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=zip-6 \
--output /optimized-jdk-21
# Second stage, Use the custom JRE and build the app image
FROM alpine:latest
ENV JAVA_HOME=/opt/jdk/jdk-21
ENV PATH="${JAVA_HOME}/bin:${PATH}"
# copy JRE from the base image
COPY --from=jre-builder /optimized-jdk-21 $JAVA_HOME
WORKDIR /usr/src/app
COPY --from=jre-builder /app/target/QualityLabPro-0.8.jar ./app.jar
ENV SPRING_PROFILES_ACTIVE=prod \
SERVER_PORT=8080
EXPOSE ${SERVER_PORT}