Skip to content

Commit 8bd087c

Browse files
committed
Re-enable dependency based JRE
It looks like this was finally fixed in a JRE 21 patch version
1 parent 961c157 commit 8bd087c

File tree

1 file changed

+21
-38
lines changed

1 file changed

+21
-38
lines changed

docker/Dockerfile

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,33 @@ RUN apk --no-cache add openjdk21-jdk openjdk21-jmods
2020

2121
ENV JAVA_MINIMAL="/opt/java-minimal"
2222

23-
#TODO: running jdeps does not work with spring-boot 2.5 or later.
24-
#TODO: Still not working with Java 21
25-
#FROM staging_area as builder
2623
# prepare dependencies for jdeps/jlink
27-
#COPY ./target/s3mock-exec.jar s3mock.jar
24+
COPY ./target/s3mock-exec.jar s3mock.jar
2825
# Spring Boot uses fat JARs, jdeps can't read them. Need to unpack JAR before running jdeps
29-
#ENV TMP_DIR="/tmp/app-jar"
30-
#RUN mkdir -p ${TMP_DIR}
31-
#RUN unzip -q s3mock.jar -d "${TMP_DIR}"
26+
ENV TMP_DIR="/tmp/app-jar"
27+
RUN mkdir -p ${TMP_DIR}
28+
RUN unzip -q s3mock.jar -d "${TMP_DIR}"
3229

33-
## find JDK dependencies dynamically from unpacked jar
34-
#RUN jdeps \
35-
## dont worry about missing modules
36-
#--ignore-missing-deps \
37-
## suppress any warnings printed to console
38-
#-q \
39-
## java release version targeting
40-
#--multi-release 17 \
41-
## output the dependencies at end of run
42-
#--print-module-deps \
43-
#--recursive \
44-
## specify the the dependencies for the jar
45-
#--class-path ${TMP_DIR}/BOOT-INF/lib/* ${TMP_DIR}/BOOT-INF/classes ${TMP_DIR} \
46-
## pipe the result of running jdeps on the app jar to file
47-
#${TMP_DIR}/org ${TMP_DIR}/BOOT-INF/classes ${TMP_DIR}/BOOT-INF/lib/*.jar > jre-deps.info \
48-
#
49-
## build minimal JRE
50-
#RUN jlink \
51-
# --verbose \
52-
# --add-modules $(cat jre-deps.info) \
53-
# --compress 2 \
54-
# --no-header-files \
55-
# --no-man-pages \
56-
# --strip-java-debug-attributes \
57-
# --output "$JAVA_MINIMAL"
30+
# find JDK dependencies dynamically from unpacked jar
31+
RUN jdeps \
32+
# don't worry about missing modules
33+
--ignore-missing-deps \
34+
# suppress any warnings printed to console
35+
-q \
36+
# java release version targeting
37+
--multi-release 21 \
38+
# output the dependencies at end of run
39+
--print-module-deps \
40+
--recursive \
41+
# specify the the dependencies for the jar
42+
--class-path "${TMP_DIR}/BOOT-INF/lib/*:${TMP_DIR}/BOOT-INF/classes:${TMP_DIR}" \
43+
# pipe the result of running jdeps on the app jar to file
44+
${TMP_DIR}/org ${TMP_DIR}/BOOT-INF/classes ${TMP_DIR}/BOOT-INF/lib/*.jar > jre-deps.info
5845

59-
#TODO: creating "static" minimal JRE here. Activate jdeps again later
60-
# create a minimal jdk assembly with those modules that we need
46+
# build minimal JRE
6147
RUN jlink \
62-
--module-path "$JAVA_HOME"/jmods \
6348
--verbose \
64-
--add-modules java.base,java.logging,java.xml,jdk.unsupported,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument,jdk.crypto.ec \
49+
--add-modules $(cat jre-deps.info),jdk.crypto.ec \
6550
--compress 2 \
6651
--no-header-files \
6752
--no-man-pages \
@@ -73,8 +58,6 @@ FROM alpine:3.22.0@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be02
7358
ENV JAVA_HOME=/opt/java-minimal
7459
ENV PATH="$PATH:$JAVA_HOME/bin"
7560

76-
#TODO: activate copy from builder stage when jdeps works again...
77-
#COPY --from=builder "$JAVA_HOME" "$JAVA_HOME"
7861
COPY --from=staging_area "$JAVA_HOME" "$JAVA_HOME"
7962
COPY ./target/s3mock-exec.jar s3mock.jar
8063

0 commit comments

Comments
 (0)