Ensure JAVA_HOME is defined as ENV
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 26 Nov 2022 05:43:57 +0000 (06:43 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 26 Nov 2022 05:43:57 +0000 (06:43 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Dockerfile

index 5461f15f3b596408361a6c34b1588c3351a33169..8db5147103d22027d1f35bfc1a7d8e0f1db3d534 100644 (file)
@@ -113,7 +113,10 @@ RUN set -ex \
 
 ARG SAPMACHINE_VERSION=11.0.17
 
+ENV JAVA_HOME /opt/jdk
+
 RUN sapmachine_install() { \
+    SAPMACHINE_MAJOR_VERSION=$(echo ${SAPMACHINE_VERSION} | cut -d. -f1); \
     ARCH=; \
     dpkgArch="$(dpkg --print-architecture)"; \
     case "${dpkgArch##*-}" in \
@@ -133,9 +136,10 @@ RUN sapmachine_install() { \
     chmod 644 /etc/apt/trusted.gpg.d/sapmachine.gpg; \
     echo "deb http://dist.sapmachine.io/debian/${ARCH}/ ./" | tee /etc/apt/sources.list.d/sapmachine.list; \
     apt-get update; \
-    apt-get install -y sapmachine-$(echo ${SAPMACHINE_VERSION} | cut -d. -f1)-jdk=${SAPMACHINE_VERSION} --no-install-recommends; \
+    apt-get install -y sapmachine-${SAPMACHINE_MAJOR_VERSION}-jdk=${SAPMACHINE_VERSION} --no-install-recommends; \
     rm -rf "$GNUPGHOME" /var/lib/apt/lists/*; \
     apt-get remove --purge --autoremove -y ca-certificates gnupg dirmngr; \
+    ln -s /usr/lib/jvm/sapmachine-${SAPMACHINE_MAJOR_VERSION} ${JAVA_HOME}; \
   }; \
   sapjvm_install() { \
     ARCH=; \
@@ -153,6 +157,7 @@ RUN sapmachine_install() { \
     bsdtar -xvf sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip -C /usr/local --strip-components=1; \
     rm -f sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip; \
     apt-get remove --purge --auto-remove -y ca-certificates curl libarchive-tools; \
+    ln -s /usr/local ${JAVA_HOME}; \
   } \
   && set -ex \
   && if [ $(echo ${SAPMACHINE_VERSION} | cut -d. -f1) -le 8 ]; then \