Skip to content

Commit 22f6881

Browse files
committed
use flag file to skip re-init
1 parent 506b8bd commit 22f6881

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

hugegraph-server/Dockerfile

+3-6
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true &&
2828
# 2nd stage: runtime env
2929
# remove zgc, which is only available on ARM-Mac with java > 13
3030
FROM openjdk:11-slim
31-
# TODO: get the version from the pom.xml
32-
ENV version=1.2.0
33-
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
3433
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
3534

3635
# TODO: use g1gc or zgc as default
@@ -64,12 +63,10 @@ RUN set -e \
6463
COPY hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
6564
COPY hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
6665
COPY hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
67-
COPY hugegraph-server/hugegraph-dist/docker/docker-init.sh .
6866
RUN chmod 755 ./docker-entrypoint.sh
69-
RUN chmod 755 ./docker-init.sh
7067

7168
EXPOSE 8080
7269
VOLUME /hugegraph-server
7370

74-
ENTRYPOINT ["/usr/bin/dumb-init", "--" ,"/bin/bash", "docker-init.sh"]
71+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
7572
CMD ["./docker-entrypoint.sh"]

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

+22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
# under the License.
1717
#
1818

19+
# create a folder to save the docker-related file
20+
DOCKER_FOLDER='./docker'
21+
mkdir -p $DOCKER_FOLDER
22+
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
28+
if [ -z "$PASSWORD" ]; then
29+
./bin/init-store.sh
30+
else
31+
echo "init hugegraph with auth"
32+
./bin/enable-auth.sh
33+
echo "$PASSWORD" | ./bin/init-store.sh
34+
fi
35+
# create a flag file to avoid re-init when restarting
36+
touch ${DOCKER_FOLDER}/${INIT_FLAG_FILE}
37+
else
38+
echo "Hugegraph Initialization already done. Skipping re-init..."
39+
fi
40+
1941
# start hugegraph
2042
# remove "-g zgc" now, which is only available on ARM-Mac with java > 13
2143
./bin/start-hugegraph.sh -j "$JAVA_OPTS"

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

-28
This file was deleted.

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)