-
Notifications
You must be signed in to change notification settings - Fork 36
/
Dockerfile-base-minimal-no-scc
79 lines (57 loc) · 2.71 KB
/
Dockerfile-base-minimal-no-scc
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
67
68
69
70
71
72
73
74
75
76
77
78
79
### CREATE SMALL LIBERTY IMAGE ###
FROM icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi as buildLiberty_minify
ARG CONFIG_DIRECTORY
# Install unzip; needed to unzip Open Liberty
USER 0
RUN yum -y install unzip
USER 1001
# Copy in a server.xml to start server with correct features set
COPY --chown=1001:0 ${CONFIG_DIRECTORY} /config
RUN features.sh
# Create a minified openliberty package for use in final image
RUN /opt/ol/wlp/bin/server package --archive=/tmp/ol_minified.zip --include=minify --os=Linux
WORKDIR /tmp
RUN unzip -q /tmp/ol_minified.zip -d /tmp/ol
### CREATE SMALL JRE IMAGE ###
FROM ibmsemeruruntime/open-11-jdk:ubi-jdk as buildjre
ARG WAR_FILE
RUN yum -y install unzip
COPY --chown=1001:0 --from=buildLiberty_minify /tmp/ol /opt/ol/
COPY --chown=1001:0 ${WAR_FILE} /tmp
COPY /jdeps/getJavaDependencies.sh /tmp
COPY /jdeps/java_modules_append.txt /tmp
COPY /jdeps/java_modules_exclude.txt /tmp
# Scan the jars in /opt/ol/wlp/lib, the jars in the app at WEB-INF/lib
# and the classes in WEB-INF/classes for Java Module Dependencies (jdeps)
# Exlcude any jdeps listed in java_modules_exclude.txt
# and add any jdeps found in java_modules_append.txt.
RUN cd /tmp && unzip $(basename ${WAR_FILE}) \
&& /tmp/getJavaDependencies.sh /opt/ol/wlp/lib --jars \
&& /tmp/getJavaDependencies.sh /tmp/WEB-INF/lib --jars \
&& /tmp/getJavaDependencies.sh /tmp/WEB-INF/classes \
&& echo -n "," >> /tmp/java_modules.txt \
&& cat /tmp/java_modules_append.txt >> /tmp/java_modules.txt \
&& cat /tmp/java_modules.txt
RUN /opt/java/openjdk/bin/jlink --no-header-files \
--no-man-pages --compress=2 \
--strip-debug \
--add-modules $(cat /tmp/java_modules.txt) \
--output /opt/jdk11-minified
### FINAL BASE IMAGE ###
### Get the ubi
FROM registry.access.redhat.com/ubi8/ubi-minimal
RUN mkdir -p /output/workarea && mkdir -p /output/.classCache \
&& chown -R 1001:0 /output && chmod -R g+rw /output
USER 1001
ARG CONFIG_DIRECTORY
### copy in the minified java11 jre
COPY --chown=1001:0 --from=buildjre /opt/jdk11-minified /opt/jdk11-minified
## copy in the minified package of open liberty
COPY --chown=1001:0 --from=buildLiberty_minify /tmp/ol /opt/ol/
COPY --chown=1001:0 --from=buildLiberty_minify /opt/ol/helpers/build/populate_scc.sh /opt/ol/helpers/build/populate_scc.sh
# Config
COPY --chown=1001:0 ${CONFIG_DIRECTORY}/* /opt/ol/wlp/usr/servers/defaultServer/
ENV PATH=/opt/ol/wlp/bin:/opt/ol/helpers/build:/opt/jdk11-minified/bin:$PATH
ENV JAVA_HOME=/opt/jdk11-minified
ENV OPENJ9_JAVA_OPTIONS="-XX:+IgnoreUnrecognizedVMOptions -XX:+IdleTuningGcOnIdle -Xshareclasses:none -Dosgi.checkConfiguration=false"
CMD ["/opt/ol/wlp/bin/server", "run", "defaultServer"]