Skip to content

Commit 5bfcaea

Browse files
aroundaboutimbajin
andauthored
fix(chore): remove zgc in dockerfile for ARM env (#2421) (#2427)
* remove zgc * Apply suggestions from code review * 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 <jin@apache.org>
1 parent 1123e85 commit 5bfcaea

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

hugegraph-server/Dockerfile

+9-10
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ COPY . /pkg
2323
WORKDIR /pkg
2424
ARG MAVEN_ARGS
2525

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

2828
# 2nd stage: runtime env
29+
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
2930
FROM openjdk:11-slim
30-
# TODO: get the version from the pom.xml
31-
ENV version=1.2.0
32-
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-$version/ /hugegraph-server
31+
32+
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-*/ /hugegraph-server/
3333
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
3434

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

42-
# 1. Install environment
42+
# 1. Install environment and init HugeGraph Sever
4343
RUN set -x \
4444
&& apt-get -q update \
4545
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
@@ -48,15 +48,14 @@ RUN set -x \
4848
curl \
4949
lsof \
5050
vim \
51+
cron \
5152
&& apt-get clean \
52-
&& rm -rf /var/lib/apt/lists/*
53-
54-
# 2. Init HugeGraph Sever
55-
RUN set -e \
53+
&& rm -rf /var/lib/apt/lists/* \
54+
&& service cron start \
5655
&& pwd && cd /hugegraph-server/ \
5756
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
5857

59-
# 3. Init docker script
58+
# 2. Init docker script
6059
COPY hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
6160
COPY hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
6261
COPY hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .

hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh

+19-12
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,31 @@
1616
# under the License.
1717
#
1818

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

22-
# set auth if needed
23-
if [[ $AUTH == "true" ]]; then
24-
# set password if use do not provide
23+
INIT_FLAG_FILE="init_complete"
24+
25+
if [ ! -f "${DOCKER_FOLDER}/${INIT_FLAG_FILE}" ]; then
26+
# wait for storage backend
27+
./bin/wait-storage.sh
2528
if [ -z "$PASSWORD" ]; then
26-
echo "you have not set the password, we will use the default password"
27-
PASSWORD="hugegraph"
29+
echo "init hugegraph with non-auth mode"
30+
./bin/init-store.sh
31+
else
32+
echo "init hugegraph with auth mode"
33+
./bin/enable-auth.sh
34+
echo "$PASSWORD" | ./bin/init-store.sh
2835
fi
29-
echo "init hugegraph with auth"
30-
./bin/enable-auth.sh
31-
echo "$PASSWORD" | ./bin/init-store.sh
36+
# create a flag file to avoid re-init when restarting
37+
touch ${DOCKER_FOLDER}/${INIT_FLAG_FILE}
3238
else
33-
./bin/init-store.sh
39+
echo "Hugegraph Initialization already done. Skipping re-init..."
3440
fi
3541

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

3946
tail -f /dev/null

hugegraph-server/hugegraph-dist/src/assembly/static/bin/enable-auth.sh

+14-12
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ GRAPH_CONF="hugegraph.properties"
3636

3737
# make a backup
3838
BAK_CONF="$TOP/conf-bak"
39-
mkdir -p "$BAK_CONF"
40-
cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
41-
cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
42-
cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"
39+
if [ ! -d "$BAK_CONF" ]; then
40+
mkdir -p "$BAK_CONF"
41+
cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
42+
cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
43+
cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"
4344

4445

45-
sed -i -e '$a\authentication: {' \
46-
-e '$a\ authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
47-
-e '$a\ authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
48-
-e '$a\ config: {tokens: conf/rest-server.properties}' \
49-
-e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}
46+
sed -i -e '$a\authentication: {' \
47+
-e '$a\ authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
48+
-e '$a\ authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
49+
-e '$a\ config: {tokens: conf/rest-server.properties}' \
50+
-e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}
5051

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

54-
sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
55+
sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
56+
fi

hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ if [[ $JAVA_VERSION -gt 9 ]]; then
127127
fi
128128

129129
# Using G1GC as the default garbage collector (Recommended for large memory machines)
130+
# mention: zgc is only available on ARM-Mac with java > 13
130131
case "$GC_OPTION" in
131132
g1|G1|g1gc)
132133
echo "Using G1GC as the default garbage collector"

hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh

+3
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ function wait_for_startup() {
139139
process_status "$server_name" "$pid" >/dev/null
140140
if [ $? -eq 1 ]; then
141141
echo "Starting $server_name failed"
142+
if [ -e "$error_file_name" ]; then
143+
rm "$error_file_name"
144+
fi
142145
return 1
143146
fi
144147

0 commit comments

Comments
 (0)