-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (39 loc) · 1.21 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
# https://gist.github.com/sumanmaity112/57d196c8f28c6051a8c8e569ec64a953#file-automated-slim-jre-dockerfile
# Thanks <3
FROM gradle:8.4.0-jdk17-jammy AS BUILD
WORKDIR /appbuild
COPY . .
RUN gradle build --no-daemon
FROM amazoncorretto:17-alpine as CORRETTO-DEPS
WORKDIR /app
COPY --from=build /appbuild/build/libs/M2K4j.jar .
# Get modules list
RUN unzip M2K4j.jar -d temp && \
jdeps \
--print-module-deps \
--ignore-missing-deps \
--recursive \
--multi-release 17 \
--class-path="./temp/BOOT-INF/lib/*" \
--module-path="./temp/BOOT-INF/lib/*" \
M2K4j.jar > modules.txt
FROM amazoncorretto:17-alpine as CORRETTO-JDK
WORKDIR /app
COPY --from=corretto-deps /app/modules.txt .
# Output a custom jre built from the modules list
RUN apk add --no-cache binutils && \
jlink \
--verbose \
--add-modules "$(cat modules.txt)" \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /jre
FROM alpine:latest AS RUN
COPY --from=corretto-jdk /jre /app/jre
COPY --from=build /appbuild/build/libs/M2K4j.jar /app/M2K4j.jar
WORKDIR /app
ARG DEBUG_OPT
ENV DEBUG_API_OPT=$DEBUG_OPT
CMD ./jre/bin/java $DEBUG_API_OPT -jar M2K4j.jar