Skip to content

Commit

Permalink
build: fix JAVA_HOME not properly set in docker image (#4333)
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
ZhangJian He authored May 6, 2024
1 parent b4ffa20 commit de5a4f2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/

Expand Down

0 comments on commit de5a4f2

Please sign in to comment.