From de5a4f21fb0e03e5aaa13ee24987f5a990b8b011 Mon Sep 17 00:00:00 2001 From: ZhangJian He Date: Mon, 6 May 2024 19:06:10 +0800 Subject: [PATCH] build: fix JAVA_HOME not properly set in docker image (#4333) ### Motivation `JAVA_HOME` env variable is not properly set. I have tested `ARG TARGETARCH` works well, when we run `docker build`, it will automatically set the value. error log below: ``` bookie3_1 | JAVA_HOME not set, using java from PATH. (/usr/bin/java) bookie1_1 | JAVA_HOME not set, using java from PATH. (/usr/bin/java) bookie3_1 | Unrecognized VM option 'PrintGCApplicationStoppedTime' bookie3_1 | Error: Could not create the Java Virtual Machine. ``` Signed-off-by: ZhangJian He --- docker/Dockerfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 87b8899b39c..1976af5e8c9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,6 +20,7 @@ FROM ubuntu:22.04 MAINTAINER Apache BookKeeper +ARG TARGETARCH ARG BK_VERSION=4.15.1 ARG DISTRO_NAME=bookkeeper-server-${BK_VERSION}-bin ARG DISTRO_URL=https://archive.apache.org/dist/bookkeeper/bookkeeper-${BK_VERSION}/${DISTRO_NAME}.tar.gz @@ -61,13 +62,15 @@ RUN set -x \ && tar -xzf "$DISTRO_NAME.tar.gz" \ && mv bookkeeper-server-${BK_VERSION}/ /opt/bookkeeper/ \ && rm -rf "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz.sha512" \ - && pip install zk-shell \ - && JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) \ - && echo networkaddress.cache.ttl=1 >> $JAVA_HOME/conf/security/java.security \ - && echo networkaddress.cache.negative.ttl=1 >> $JAVA_HOME/conf/security/java.security + && pip install zk-shell WORKDIR /opt/bookkeeper +ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-$TARGETARCH + +RUN echo networkaddress.cache.ttl=1 >> $JAVA_HOME/conf/security/java.security \ + && echo networkaddress.cache.negative.ttl=1 >> $JAVA_HOME/conf/security/java.security + COPY scripts /opt/bookkeeper/scripts RUN chmod +x -R /opt/bookkeeper/scripts/