This is an automated email from the ASF dual-hosted git repository.

shoothzj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new de5a4f21fb build: fix JAVA_HOME not properly set in docker image 
(#4333)
de5a4f21fb is described below

commit de5a4f21fb0e03e5aaa13ee24987f5a990b8b011
Author: ZhangJian He <[email protected]>
AuthorDate: Mon May 6 19:06:10 2024 +0800

    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 <[email protected]>
---
 docker/Dockerfile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/docker/Dockerfile b/docker/Dockerfile
index 87b8899b39..1976af5e8c 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -20,6 +20,7 @@
 FROM ubuntu:22.04
 MAINTAINER Apache BookKeeper <[email protected]>
 
+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/
 

Reply via email to