2024-09-25 07:15:38 +03:00
|
|
|
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" ]
|
|
|
|
|
2024-10-09 12:16:48 +03:00
|
|
|
ARG JAVA_VERSION_MAJOR
|
|
|
|
## modern "jlink --compress" approach
|
|
|
|
ENV JLINK_COMPRESS='zip-1'
|
|
|
|
|
2024-09-25 07:15:38 +03:00
|
|
|
RUN rm -rf /jre ; \
|
2024-10-09 12:16:48 +03:00
|
|
|
if [ "${JAVA_VERSION_MAJOR}" = 17 ] ; then \
|
|
|
|
## legacy "jlink --compress" approach
|
|
|
|
JLINK_COMPRESS='1' ; \
|
|
|
|
fi ; \
|
2024-09-25 07:15:38 +03:00
|
|
|
jlink \
|
|
|
|
--add-modules ALL-MODULE-PATH \
|
|
|
|
--no-man-pages \
|
|
|
|
--no-header-files \
|
2024-10-09 12:16:48 +03:00
|
|
|
--compress=${JLINK_COMPRESS} \
|
2024-09-25 07:15:38 +03:00
|
|
|
--output /jre \
|
|
|
|
; \
|
|
|
|
cd /jre ; \
|
|
|
|
rm -rf \
|
|
|
|
lib/security/cacerts \
|
|
|
|
lib/security/krb5.conf \
|
2024-10-09 11:49:55 +03:00
|
|
|
lib/security/public_suffix_list.dat \
|
2024-09-25 07:15:38 +03:00
|
|
|
; \
|
|
|
|
ln -sv /etc/ssl/certs/java/cacerts lib/security/ ; \
|
|
|
|
ln -sv /etc/krb5.conf lib/security/ ; \
|
2024-10-09 11:49:55 +03:00
|
|
|
ln -sv /usr/local/share/publicsuffix/public_suffix_list.dat lib/security/ ; \
|
2024-09-25 07:15:38 +03:00
|
|
|
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
|