Skip to content

Commit

Permalink
fix(chore): remove zgc in dockerfile for ARM env (#2421)
Browse files Browse the repository at this point in the history
* remove zgc

* Apply suggestions from code review

Co-authored-by: imbajin <[email protected]>

* add comment for hugegraph-server.sh

* fix enable-auth.sh

* init store in entrypoint

* use flag file to skip re-init

* delete tar.gz

* simply dockerfile

* mvn optimize

* simply dockerfile

* add init log in docker

---------

Co-authored-by: imbajin <[email protected]>
  • Loading branch information
aroundabout and imbajin authored Jan 26, 2024
1 parent 1dd0580 commit b980df8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
19 changes: 9 additions & 10 deletions hugegraph-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ COPY . /pkg
WORKDIR /pkg
ARG MAVEN_ARGS

RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l
RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l && rm ./hugegraph-server/*.tar.gz

# 2nd stage: runtime env
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
FROM openjdk:11-slim
# TODO: get the version from the pom.xml
ENV version=1.2.0
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-$version/ /hugegraph-server

COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-*/ /hugegraph-server/
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>"

# TODO: use g1gc or zgc as default
Expand All @@ -39,7 +39,7 @@ ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:Max
#COPY . /hugegraph/hugegraph-server
WORKDIR /hugegraph-server/

# 1. Install environment
# 1. Install environment and init HugeGraph Sever
RUN set -x \
&& apt-get -q update \
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
Expand All @@ -48,15 +48,14 @@ RUN set -x \
curl \
lsof \
vim \
cron \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# 2. Init HugeGraph Sever
RUN set -e \
&& rm -rf /var/lib/apt/lists/* \
&& service cron start \
&& pwd && cd /hugegraph-server/ \
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties

# 3. Init docker script
# 2. Init docker script
COPY hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
COPY hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
COPY hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
Expand Down
31 changes: 19 additions & 12 deletions hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@
# under the License.
#

# wait for storage like cassandra
./bin/wait-storage.sh
# create a folder to save the docker-related file
DOCKER_FOLDER='./docker'
mkdir -p $DOCKER_FOLDER

# set auth if needed
if [[ $AUTH == "true" ]]; then
# set password if use do not provide
INIT_FLAG_FILE="init_complete"

if [ ! -f "${DOCKER_FOLDER}/${INIT_FLAG_FILE}" ]; then
# wait for storage backend
./bin/wait-storage.sh
if [ -z "$PASSWORD" ]; then
echo "you have not set the password, we will use the default password"
PASSWORD="hugegraph"
echo "init hugegraph with non-auth mode"
./bin/init-store.sh
else
echo "init hugegraph with auth mode"
./bin/enable-auth.sh
echo "$PASSWORD" | ./bin/init-store.sh
fi
echo "init hugegraph with auth"
./bin/enable-auth.sh
echo "$PASSWORD" | ./bin/init-store.sh
# create a flag file to avoid re-init when restarting
touch ${DOCKER_FOLDER}/${INIT_FLAG_FILE}
else
./bin/init-store.sh
echo "Hugegraph Initialization already done. Skipping re-init..."
fi

# start hugegraph
./bin/start-hugegraph.sh -j "$JAVA_OPTS" -g zgc
# remove "-g zgc" now, which is only available on ARM-Mac with java > 13
./bin/start-hugegraph.sh -j "$JAVA_OPTS"

tail -f /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ GRAPH_CONF="hugegraph.properties"

# make a backup
BAK_CONF="$TOP/conf-bak"
mkdir -p "$BAK_CONF"
cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"
if [ ! -d "$BAK_CONF" ]; then
mkdir -p "$BAK_CONF"
cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"


sed -i -e '$a\authentication: {' \
-e '$a\ authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
-e '$a\ authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
-e '$a\ config: {tokens: conf/rest-server.properties}' \
-e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}
sed -i -e '$a\authentication: {' \
-e '$a\ authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
-e '$a\ authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
-e '$a\ config: {tokens: conf/rest-server.properties}' \
-e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}

sed -i -e '$a\auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
-e '$a\auth.graph_store=hugegraph' ${CONF}/${REST_SERVER_CONF}
sed -i -e '$a\auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
-e '$a\auth.graph_store=hugegraph' ${CONF}/${REST_SERVER_CONF}

sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ if [[ $JAVA_VERSION -gt 9 ]]; then
fi

# Using G1GC as the default garbage collector (Recommended for large memory machines)
# mention: zgc is only available on ARM-Mac with java > 13
case "$GC_OPTION" in
g1|G1|g1gc)
echo "Using G1GC as the default garbage collector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ function wait_for_startup() {
process_status "$server_name" "$pid" >/dev/null
if [ $? -eq 1 ]; then
echo "Starting $server_name failed"
if [ -e "$error_file_name" ]; then
rm "$error_file_name"
fi
return 1
fi

Expand Down

0 comments on commit b980df8

Please sign in to comment.