# ------------------------------------------------------------------------------ # NOTE: THIS DOCKERFILE IS GENERATED VIA "build_latest.sh" or "update_multiarch.sh" # # PLEASE DO NOT EDIT IT DIRECTLY. # ------------------------------------------------------------------------------ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # FROM alpine:3.14 ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' RUN apk add --no-cache tzdata --virtual .build-deps curl binutils zstd \ && GLIBC_VER="2.33-r0" \ && ALPINE_GLIBC_REPO="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" \ && GCC_LIBS_URL="https://archive.archlinux.org/packages/g/gcc-libs/gcc-libs-10.1.0-2-x86_64.pkg.tar.zst" \ && GCC_LIBS_SHA256="f80320a03ff73e82271064e4f684cd58d7dbdb07aa06a2c4eea8e0f3c507c45c" \ && ZLIB_URL="https://archive.archlinux.org/packages/z/zlib/zlib-1%3A1.2.11-3-x86_64.pkg.tar.xz" \ && ZLIB_SHA256=17aede0b9f8baa789c5aa3f358fbf8c68a5f1228c5e6cba1a5dd34102ef4d4e5 \ && curl -LfsS https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \ && SGERRAND_RSA_SHA256="823b54589c93b02497f1ba4dc622eaef9c813e6b0f0ebbb2f771e32adf9f4ef2" \ && echo "${SGERRAND_RSA_SHA256} */etc/apk/keys/sgerrand.rsa.pub" | sha256sum -c - \ && curl -LfsS ${ALPINE_GLIBC_REPO}/${GLIBC_VER}/glibc-${GLIBC_VER}.apk > /tmp/glibc-${GLIBC_VER}.apk \ && apk add --no-cache /tmp/glibc-${GLIBC_VER}.apk \ && curl -LfsS ${ALPINE_GLIBC_REPO}/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk > /tmp/glibc-bin-${GLIBC_VER}.apk \ && apk add --no-cache /tmp/glibc-bin-${GLIBC_VER}.apk \ && curl -Ls ${ALPINE_GLIBC_REPO}/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk > /tmp/glibc-i18n-${GLIBC_VER}.apk \ && apk add --no-cache /tmp/glibc-i18n-${GLIBC_VER}.apk \ && /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true \ && echo "export LANG=$LANG" > /etc/profile.d/locale.sh \ && curl -LfsS ${GCC_LIBS_URL} -o /tmp/gcc-libs.tar.zst \ && echo "${GCC_LIBS_SHA256} */tmp/gcc-libs.tar.zst" | sha256sum -c - \ && mkdir /tmp/gcc \ && zstd -d /tmp/gcc-libs.tar.zst --output-dir-flat /tmp \ && tar -xf /tmp/gcc-libs.tar -C /tmp/gcc \ && mv /tmp/gcc/usr/lib/libgcc* /tmp/gcc/usr/lib/libstdc++* /usr/glibc-compat/lib \ && strip /usr/glibc-compat/lib/libgcc_s.so.* /usr/glibc-compat/lib/libstdc++.so* \ && curl -LfsS ${ZLIB_URL} -o /tmp/libz.tar.xz \ && echo "${ZLIB_SHA256} */tmp/libz.tar.xz" | sha256sum -c - \ && mkdir /tmp/libz \ && tar -xf /tmp/libz.tar.xz -C /tmp/libz \ && mv /tmp/libz/usr/lib/libz.so* /usr/glibc-compat/lib \ && apk del --purge .build-deps glibc-i18n \ && rm -rf /tmp/*.apk /tmp/gcc /tmp/gcc-libs.tar* /tmp/libz /tmp/libz.tar.xz /var/cache/apk/* ENV JAVA_VERSION jdk-11.0.11+9_openj9-0.26.0 RUN set -eux; \ apk add --no-cache --virtual .fetch-deps curl; \ ARCH="$(apk --print-arch)"; \ case "${ARCH}" in \ amd64|x86_64) \ ESUM='a605ab06f76533d44ce0828bd96836cc9c0e71ec3df3f8672052ea98dcbcca22'; \ BINARY_URL='https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.11%2B9_openj9-0.26.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.11_9_openj9-0.26.0.tar.gz'; \ ;; \ *) \ echo "Unsupported arch: ${ARCH}"; \ exit 1; \ ;; \ esac; \ curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \ echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ mkdir -p /opt/java/openjdk; \ cd /opt/java/openjdk; \ tar -xf /tmp/openjdk.tar.gz --strip-components=1; \ apk del --purge .fetch-deps; \ rm -rf /var/cache/apk/*; \ rm -rf /tmp/openjdk.tar.gz; ENV JAVA_HOME=/opt/java/openjdk \ PATH="/opt/java/openjdk/bin:$PATH" ENV JAVA_TOOL_OPTIONS="-XX:+IgnoreUnrecognizedVMOptions -XX:+IdleTuningGcOnIdle -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,readonly,nonFatal" # Create OpenJ9 SharedClassCache (SCC) for bootclasses to improve the java startup. # Downloads and runs tomcat to generate SCC for bootclasses at /opt/java/.scc/openj9_system_scc # Does a dry-run and calculates the optimal cache size and recreates the cache with the appropriate size. # With SCC, OpenJ9 startup is improved ~50% with an increase in image size of ~14MB # Application classes can be create a separate cache layer with this as the base for further startup improvement RUN set -eux; \ apk add --no-cache --virtual .scc-deps curl; \ unset OPENJ9_JAVA_OPTIONS; \ SCC_SIZE="50m"; \ DOWNLOAD_PATH_TOMCAT=/tmp/tomcat; \ INSTALL_PATH_TOMCAT=/opt/tomcat-home; \ TOMCAT_CHECKSUM="0db27185d9fc3174f2c670f814df3dda8a008b89d1a38a5d96cbbe119767ebfb1cf0bce956b27954aee9be19c4a7b91f2579d967932207976322033a86075f98"; \ TOMCAT_DWNLD_URL="https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.35/bin/apache-tomcat-9.0.35.tar.gz"; \ \ mkdir -p "${DOWNLOAD_PATH_TOMCAT}" "${INSTALL_PATH_TOMCAT}"; \ curl -LfsSo "${DOWNLOAD_PATH_TOMCAT}"/tomcat.tar.gz "${TOMCAT_DWNLD_URL}"; \ echo "${TOMCAT_CHECKSUM} *${DOWNLOAD_PATH_TOMCAT}/tomcat.tar.gz" | sha512sum -c -; \ tar -xf "${DOWNLOAD_PATH_TOMCAT}"/tomcat.tar.gz -C "${INSTALL_PATH_TOMCAT}" --strip-components=1; \ rm -rf "${DOWNLOAD_PATH_TOMCAT}"; \ \ java -Xshareclasses:name=dry_run_scc,cacheDir=/opt/java/.scc,bootClassesOnly,nonFatal,createLayer -Xscmx$SCC_SIZE -version; \ export OPENJ9_JAVA_OPTIONS="-Xshareclasses:name=dry_run_scc,cacheDir=/opt/java/.scc,bootClassesOnly,nonFatal"; \ "${INSTALL_PATH_TOMCAT}"/bin/startup.sh; \ sleep 5; \ "${INSTALL_PATH_TOMCAT}"/bin/shutdown.sh -force; \ sleep 15; \ FULL=$( (java -Xshareclasses:name=dry_run_scc,cacheDir=/opt/java/.scc,printallStats 2>&1 || true) | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'); \ DST_CACHE=$(java -Xshareclasses:name=dry_run_scc,cacheDir=/opt/java/.scc,destroy 2>&1 || true); \ SCC_SIZE=$(echo $SCC_SIZE | sed 's/.$//'); \ SCC_SIZE=$(awk "BEGIN {print int($SCC_SIZE * $FULL / 100.0)}"); \ [ "${SCC_SIZE}" -eq 0 ] && SCC_SIZE=1; \ SCC_SIZE="${SCC_SIZE}m"; \ java -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,bootClassesOnly,nonFatal,createLayer -Xscmx$SCC_SIZE -version; \ unset OPENJ9_JAVA_OPTIONS; \ \ export OPENJ9_JAVA_OPTIONS="-Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,bootClassesOnly,nonFatal"; \ "${INSTALL_PATH_TOMCAT}"/bin/startup.sh; \ sleep 5; \ "${INSTALL_PATH_TOMCAT}"/bin/shutdown.sh -force; \ sleep 5; \ FULL=$( (java -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,printallStats 2>&1 || true) | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'); \ echo "SCC layer is $FULL% full."; \ rm -rf "${INSTALL_PATH_TOMCAT}"; \ if [ -d "/opt/java/.scc" ]; then \ chmod -R 0777 /opt/java/.scc; \ fi; \ \ apk del --purge .scc-deps; \ rm -rf /var/cache/apk/*; \ echo "SCC generation phase completed"; CMD ["jshell"]