86 lines
2.1 KiB
Docker
86 lines
2.1 KiB
Docker
ARG IMAGE_VERSION
|
|
ARG JAVA_VERSION_MAJOR
|
|
FROM docker.io/rockdrilla/graalvm-debian:base-${IMAGE_VERSION} AS base
|
|
FROM docker.io/rockdrilla/graalvm-debian:jdk-${JAVA_VERSION_MAJOR}-${IMAGE_VERSION} AS jdk
|
|
|
|
## ---
|
|
|
|
FROM jdk as jdk-to-jre
|
|
SHELL [ "/bin/sh", "-ec" ]
|
|
|
|
ARG JAVA_VERSION_MAJOR
|
|
## modern "jlink --compress" approach
|
|
ENV JLINK_COMPRESS='zip-1'
|
|
|
|
RUN rm -rf /jre ; \
|
|
if [ "${JAVA_VERSION_MAJOR}" = 17 ] ; then \
|
|
## legacy "jlink --compress" approach
|
|
JLINK_COMPRESS='1' ; \
|
|
fi ; \
|
|
jlink \
|
|
--add-modules ALL-MODULE-PATH \
|
|
--no-man-pages \
|
|
--no-header-files \
|
|
--compress=${JLINK_COMPRESS} \
|
|
--output /jre \
|
|
; \
|
|
cd /jre ; \
|
|
rm -rf \
|
|
lib/security/cacerts \
|
|
lib/security/krb5.conf \
|
|
lib/security/public_suffix_list.dat \
|
|
; \
|
|
ln -sv /etc/ssl/certs/java/cacerts lib/security/ ; \
|
|
ln -sv /etc/krb5.conf lib/security/ ; \
|
|
ln -sv /usr/local/share/publicsuffix/public_suffix_list.dat lib/security/ ; \
|
|
chmod -R go-w /jre
|
|
|
|
RUN rm -rf "${JAVA_HOME}" ; \
|
|
mkdir -p "${JAVA_HOME}" ; \
|
|
tar -C /jre -cf - . | tar -C "${JAVA_HOME}" -xf - ; \
|
|
rm -rf /jre ; \
|
|
find "${JAVA_HOME}/" -name '*.so' -exec dirname '{}' '+' \
|
|
| sort -uV > ld.so.conf ; \
|
|
chmod -R go-w "${JAVA_HOME}/"
|
|
|
|
WORKDIR ${JAVA_HOME}
|
|
|
|
## https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840
|
|
## https://openjdk.java.net/jeps/341
|
|
RUN ldconfig ; \
|
|
java -Xshare:dump
|
|
|
|
RUN find /tmp/ -mindepth 1 -ls -delete
|
|
|
|
## deduplicate (!)
|
|
RUN apt-install.sh jdupes ; \
|
|
apt-clean.sh ; \
|
|
echo ; \
|
|
du -xd1 "${PWD}/" | sort -Vk2 ; \
|
|
echo ; \
|
|
jdupes -1LSpr "${PWD}/" ; \
|
|
echo ; \
|
|
du -xd1 "${PWD}/" | sort -Vk2 ; \
|
|
echo
|
|
|
|
## ---
|
|
|
|
FROM base AS jre
|
|
SHELL [ "/bin/sh", "-ec" ]
|
|
|
|
COPY /Dockerfile.jre /usr/local/share/
|
|
|
|
ENV JAVA_HOME=/opt/graalvm
|
|
|
|
COPY --from=jdk-to-jre "${JAVA_HOME}/" "${JAVA_HOME}/"
|
|
|
|
RUN ln -s "${JAVA_HOME}/ld.so.conf" /etc/ld.so.conf.d/graalvm.conf ; \
|
|
ldconfig
|
|
|
|
ENV PATH="${JAVA_HOME}/bin:${PATH}" \
|
|
MALLOC_ARENA_MAX=4
|
|
|
|
## qa/smoke
|
|
RUN set -xv ; java -version ; \
|
|
find /tmp/ -mindepth 1 -ls -delete
|