You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by ji...@apache.org on 2023/03/21 12:57:03 UTC

[incubator-hugegraph-toolchain] branch master updated: chore(hubble): use latest code in Dockerfile (#440)

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

jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-toolchain.git


The following commit(s) were added to refs/heads/master by this push:
     new 11ee775b chore(hubble): use latest code in Dockerfile (#440)
11ee775b is described below

commit 11ee775b6849caebf47fd1ac8f120eece309d47a
Author: Simon Cheung <mi...@apache.org>
AuthorDate: Tue Mar 21 20:56:56 2023 +0800

    chore(hubble): use latest code in Dockerfile (#440)
    
    
    * Update hubble-ci.yml
    
    * Update README.md
    
    ---------
    
    Co-authored-by: imbajin <ji...@apache.org>
---
 README.md                                          |  4 +-
 hugegraph-hubble/Dockerfile                        | 32 ++++++----
 hugegraph-hubble/README.md                         | 10 ++-
 .../assembly/static/bin/start-hubble.sh            | 71 +++++++++++-----------
 4 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/README.md b/README.md
index d6558eae..2e6b2e78 100644
--- a/README.md
+++ b/README.md
@@ -13,13 +13,13 @@
 ## Modules
 
 - [hugegraph-loader](./hugegraph-loader): Loading datasets into the HugeGraph from multiple data sources.
-- [hugegraph-hubble](./hugegraph-hubble): Online HugeGraph management and analysis dashboard (Include: data loading, schema management, graph traverser and display)
+- [hugegraph-hubble](./hugegraph-hubble): Online HugeGraph management and analysis dashboard (Include: data loading, schema management, graph traverser and display). We can use `docker run -itd --name=hubble -p 8088:8088 hugegraph/hubble` to quickly start [hubble](https://hub.docker.com/r/hugegraph/hubble).
 - [hugegraph-tools](./hugegraph-tools): Command line tool for deploying, managing and backing-up/restoring graphs from HugeGraph.
 - [hugegraph-client](./hugegraph-client): A Java-written client for HugeGraph, providing `RESTful` APIs for accessing graph vertex/edge/schema/gremlin/variables and traversals etc.
 
 ## Maven Dependencies
 
-You could use import the dependencies in maven like this
+You could use import the dependencies in `maven` like this:
 
 ```xml
   <dependency>
diff --git a/hugegraph-hubble/Dockerfile b/hugegraph-hubble/Dockerfile
index 51b0aa24..4518d82f 100644
--- a/hugegraph-hubble/Dockerfile
+++ b/hugegraph-hubble/Dockerfile
@@ -5,7 +5,9 @@
 # The ASF licenses this file to You under the Apache License, Version 2.0
 # (the "License"); you may not use this file except in compliance with
 # the License.  You may obtain a copy of the License at
-#     http://www.apache.org/licenses/LICENSE-2.0
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -13,22 +15,26 @@
 # limitations under the License.
 #
 
-FROM ubuntu:xenial
+FROM maven:3.9.0-eclipse-temurin-11 AS build
 
 RUN set -x \
     && apt-get -q update \
-    && apt-get -q install -y --no-install-recommends --no-install-suggests \
-       curl \
-       lsof \
-       g++ \
-       gcc \
-       openjdk-8-jdk \
+    && apt-get install -y nodejs npm \
+    && npm install --global yarn \
     && apt-get clean
 
-ENV HUBBLE_HOME /opt/hugegraph-hubble
-WORKDIR ${HUBBLE_HOME}
+COPY . /pkg
+WORKDIR /pkg
 
-COPY ./hugegraph-hubble $HUBBLE_HOME
-EXPOSE 8088
+RUN set -x \
+    && cd /pkg/hugegraph-hubble/ \
+    && mvn package -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true
 
-ENTRYPOINT ["./bin/start-hubble.sh"]
+
+FROM openjdk:11-slim
+
+COPY --from=build /pkg/hugegraph-hubble/apache-hugegraph-hubble-incubating-*/ /hubble
+WORKDIR /hubble/
+
+EXPOSE 8088
+ENTRYPOINT ["./bin/start-hubble.sh", "-f true"]
diff --git a/hugegraph-hubble/README.md b/hugegraph-hubble/README.md
index 96febe1f..ce467540 100644
--- a/hugegraph-hubble/README.md
+++ b/hugegraph-hubble/README.md
@@ -1,8 +1,8 @@
-# hugegraph-hubble
+# Apache HugeGraph-Hubble
 
 [![License](https://img.shields.io/badge/license-Apache%202-0E78BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
-[![Build Status](https://travis-ci.org/hugegraph/hugegraph-hubble.svg?branch=master)](https://travis-ci.org/hugegraph/hugegraph-hubble)
-[![codecov](https://codecov.io/gh/hugegraph/hugegraph-hubble/branch/master/graph/badge.svg)](https://codecov.io/gh/hugegraph/hugegraph-hubble)
+[![hugegraph-hubble-ci](https://github.com/apache/incubator-hugegraph-toolchain/actions/workflows/hubble-ci.yml/badge.svg?branch=master)](https://github.com/apache/incubator-hugegraph-toolchain/actions/workflows/hubble-ci.yml)
+[![CodeQL](https://github.com/apache/incubator-hugegraph-toolchain/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/incubator-hugegraph-toolchain/actions/workflows/codeql-analysis.yml)
 
 hugegraph-hubble is a graph management and analysis platform that provides features: graph data load, schema management, graph relationship analysis and graphical display.
 
@@ -13,6 +13,10 @@ hugegraph-hubble is a graph management and analysis platform that provides featu
 - Schema management, supporting to easily perform schema manipulation and display
 - Graph analysis and graphical display, supporting to build query via the gremlin or algorithms with a little effort then will get cool graphical results
 
+## Quick Start
+
+We can use `docker run -itd --name=hubble -p 8088:8088 hugegraph/hubble` to quickly start [hubble](https://hub.docker.com/r/hugegraph/hubble).
+
 ## Doc
 
 [The hubble homepage](https://hugegraph.apache.org/docs/quickstart/hugegraph-hubble/) contains more information about it.
diff --git a/hugegraph-hubble/hubble-dist/assembly/static/bin/start-hubble.sh b/hugegraph-hubble/hubble-dist/assembly/static/bin/start-hubble.sh
index 3b059800..2626e0a5 100644
--- a/hugegraph-hubble/hubble-dist/assembly/static/bin/start-hubble.sh
+++ b/hugegraph-hubble/hubble-dist/assembly/static/bin/start-hubble.sh
@@ -30,13 +30,6 @@ PID_FILE=${BIN_PATH}/pid
 
 . "${BIN_PATH}"/common_functions
 
-print_usage() {
-    echo "  usage: start-hubble.sh [options]"
-    echo "  options: "
-    echo "  -d,--debug      Start program in debug mode"
-    echo "  -h,--help       Display help information"
-}
-
 java_env_check
 
 if [[ ! -d ${LOG_PATH} ]]; then
@@ -49,49 +42,53 @@ for jar in "${LIB_PATH}"/*.jar; do
     class_path=${class_path}:${jar}
 done
 
-java_opts="-Xms512m"
-java_debug_opts=""
-while [[ $# -gt 0 ]]; do
-    case $1 in
-        --help|-help|-h)
-        print_usage
-        exit 0
-        ;;
-        --debug|-d)
-        java_debug_opts=" -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
-        ;;
+JAVA_OPTS="-Xms512m"
+JAVA_DEBUG_OPTS=""
+FOREGROUND="false"
+
+while getopts "f:d" arg; do
+    case ${arg} in
+        f) FOREGROUND="$OPTARG" ;;
+        d) JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" ;;
+        ?) echo "USAGE: $0 [-f true|false] [-d] " && exit 1 ;;
     esac
-    shift
 done
 
 if [[ -f ${PID_FILE} ]] ; then
-    pid=$(cat "${PID_FILE}")
-    if kill -0 "${pid}" > /dev/null 2>&1; then
-        echo "HugeGraphHubble is running as process ${pid}, please stop it first!"
+    PID=$(cat "${PID_FILE}")
+    if kill -0 "${PID}" > /dev/null 2>&1; then
+        echo "HugeGraphHubble is running as process ${PID}, please stop it first!"
         exit 1
     else
         rm "${PID_FILE}"
     fi
 fi
 
-main_class="org.apache.hugegraph.HugeGraphHubble"
-args=${CONF_PATH}/hugegraph-hubble.properties
-log=${LOG_PATH}/hugegraph-hubble.log
+MAIN_CLASS="org.apache.hugegraph.HugeGraphHubble"
+ARGS=${CONF_PATH}/hugegraph-hubble.properties
+LOG=${LOG_PATH}/hugegraph-hubble.log
+
+if [[ $FOREGROUND == "false" ]]; then
+    echo "Starting Hubble in daemon mode..."
+    nice -n 0 java -server ${JAVA_OPTS} ${JAVA_DEBUG_OPTS} -Dhubble.home.path="${HOME_PATH}" \
+  -cp ${class_path} ${MAIN_CLASS} ${ARGS} > ${LOG} 2>&1 < /dev/null &
+else
+    echo "Starting Hubble in foreground mode..."
+    nice -n 0 java -server ${JAVA_OPTS} ${JAVA_DEBUG_OPTS} -Dhubble.home.path="${HOME_PATH}" \
+  -cp ${class_path} ${MAIN_CLASS} ${ARGS} > ${LOG} 2>&1 < /dev/null
+fi
 
-echo -n "starting HugeGraphHubble "
-nohup nice -n 0 java -server ${java_opts} ${java_debug_opts} -Dhubble.home.path="${HOME_PATH}" \
-  -cp ${class_path} ${main_class} ${args} > ${log} 2>&1 < /dev/null &
-pid=$!
-echo ${pid} > "${PID_FILE}"
+PID=$!
+echo ${PID} > "${PID_FILE}"
 
 # wait hubble start
-timeout_s=30
-server_host=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.host)
-server_port=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.port)
-server_url="http://${server_host}:${server_port}/actuator/health"
+TIMEOUT_S=30
+SERVER_HOST=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.host)
+SERVER_PORT=$(read_property "${CONF_PATH}"/hugegraph-hubble.properties hubble.port)
+SERVER_URL="http://${SERVER_HOST}:${SERVER_PORT}/actuator/health"
 
-wait_for_startup "${server_url}" ${timeout_s} || {
-    cat "${log}"
+wait_for_startup "${SERVER_URL}" ${TIMEOUT_S} || {
+    cat "${LOG}"
     exit 1
 }
-echo "logging to ${log}, please check it"
+echo "logging to ${LOG}, please check it"