-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (47 loc) · 1.78 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
# A JDK 9 with Alpine Linux
FROM alpine:3.6 as builder
# Add the musl-based JDK 9 distribution
WORKDIR /usr/lib/jvm
# Download from http://jdk.java.net/9/
ARG OPENJDK9_ALPINE_URL=http://download.java.net/java/jdk9-alpine/archive/181/binaries/jdk-9-ea+181_linux-x64-musl_bin.tar.gz
# Download and untar openjdk9-alpine from $OPENJDK9_ALPINE_URL
RUN wget -c -O- --header "Cookie: oraclelicense=accept-securebackup-cookie" $OPENJDK9_ALPINE_URL \
| tar -zxC /usr/lib/jvm
# Default to UTF-8 file.encoding
ENV LANG C.UTF-8
# Set up env variables
ENV JAVA_HOME /usr/lib/jvm/jdk-9
ENV PATH=$PATH:$JAVA_HOME/bin
WORKDIR /app
RUN mkdir -p /app/src
COPY ./src /app/src
RUN mkdir -p build/classes/main
RUN javac -d build/classes/main \
src/mjg123.module/module-info.java \
src/mjg123.module/mjg123/module/Main.java
RUN mkdir -p build/jmods
RUN jar --create --file build/jmods/mjg123-main-1.0-SNAPSHOT.jar \
--main-class mjg123.module.Main \
-C build/classes/main .
ENV TARGET_JMODS=$JAVA_HOME/jmods
# RUN ls -la $JAVA_HOME/bin
RUN jlink --module-path build/jmods:$TARGET_JMODS \
--strip-debug \
--vm server \
--compress 2 \
--class-for-name \
--no-header-files \
--no-man-pages \
--dedup-legal-notices=error-if-not-same-content \
--add-modules mjg123.module \
--output build/jre/native
# RUN du -csh build/jre/native
# Builder Stage is all done
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app/build/jre/native/bin
COPY --from=builder /app/build/jre/native /app/build/jre/native
RUN /app/build/jre/native/bin/java -Xshare:dump
# below to enable class loader logging for add option:
# "-Xlog:class+load=info",
CMD ["/app/build/jre/native/bin/java", "-Xshare:on", "-m", "mjg123.module"]