-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Cassandra with docker-compose in server (#2307)
## Main Changes 1. change the dockerfile, adding the shell to wait for storage backend and use a docker-entrypoint.sh to manage the starting process. 2. delete a deprecated class in gremlin-console.sh (reference: [doc of ScriptExecutor](https://tinkerpop.apache.org/javadocs/3.2.3/full/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptExecutor.html)) 3. add a healthy check in docker-compose 4. add an example folder where we can put all the template docker-compose.yml here 5. add `*swagger-ui*` in gitignore, which appears after you compile the source code locally. --------- Co-authored-by: imbajin <[email protected]>
- Loading branch information
1 parent
73329ce
commit d4b95ca
Showing
11 changed files
with
229 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,8 @@ COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph | |
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>" | ||
|
||
# TODO: use g1gc or zgc as default | ||
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" | ||
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \ | ||
HUGEGRAPH_HOME="hugegraph" | ||
|
||
#COPY . /hugegraph/hugegraph-server | ||
WORKDIR /hugegraph/ | ||
|
@@ -50,11 +51,16 @@ RUN set -x \ | |
# 2. Init HugeGraph Sever | ||
RUN set -e \ | ||
&& pwd && cd /hugegraph/ \ | ||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \ | ||
&& ./bin/init-store.sh | ||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties | ||
|
||
# 3. Init docker script | ||
COPY hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts | ||
COPY hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts | ||
COPY hugegraph-dist/docker/docker-entrypoint.sh . | ||
RUN chmod 755 ./docker-entrypoint.sh | ||
|
||
EXPOSE 8080 | ||
VOLUME /hugegraph | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--"] | ||
CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"] | ||
CMD ["./docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with this | ||
# work for additional information regarding copyright ownership. 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 | ||
# | ||
# 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. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
|
||
./bin/wait-storage.sh | ||
|
||
./bin/init-store.sh | ||
|
||
./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc |
61 changes: 61 additions & 0 deletions
61
hugegraph-dist/docker/example/docker-compose-cassandra.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# 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 | ||
# | ||
# 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. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
version: "3" | ||
|
||
services: | ||
graph: | ||
image: hugegraph/hugegraph | ||
container_name: cas-graph | ||
ports: | ||
- 18080:8080 | ||
environment: | ||
hugegraph.backend: cassandra | ||
hugegraph.serializer: cassandra | ||
hugegraph.cassandra.host: cas-cassandra | ||
hugegraph.cassandra.port: 9042 | ||
networks: | ||
- ca-network | ||
depends_on: | ||
- cassandra | ||
healthcheck: | ||
test: ["CMD", "bin/gremlin-console.sh", "--" ,"-e", "scripts/remote-connect.groovy"] | ||
interval: 10s | ||
timeout: 30s | ||
retries: 3 | ||
|
||
cassandra: | ||
image: cassandra:4 | ||
container_name: cas-cassandra | ||
ports: | ||
- 7000:7000 | ||
- 9042:9042 | ||
security_opt: | ||
- seccomp:unconfined | ||
networks: | ||
- ca-network | ||
healthcheck: | ||
test: ["CMD", "cqlsh", "--execute", "describe keyspaces;"] | ||
interval: 10s | ||
timeout: 30s | ||
retries: 5 | ||
|
||
networks: | ||
ca-network: | ||
|
||
volumes: | ||
hugegraph-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. 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 | ||
* | ||
* 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. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import org.apache.hugegraph.HugeFactory | ||
import org.apache.hugegraph.dist.RegisterUtil | ||
|
||
// register all the backend to avoid changes if docker needs to support othre backend | ||
RegisterUtil.registerPlugins() | ||
RegisterUtil.registerRocksDB() | ||
RegisterUtil.registerCassandra() | ||
RegisterUtil.registerScyllaDB() | ||
RegisterUtil.registerHBase() | ||
RegisterUtil.registerMysql() | ||
RegisterUtil.registerPalo() | ||
RegisterUtil.registerPostgresql() | ||
|
||
graph = HugeFactory.open('./conf/graphs/hugegraph.properties') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. 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 | ||
* | ||
* 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. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
:remote connect tinkerpop.server conf/remote.yaml | ||
:> hugegraph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
hugegraph-dist/src/assembly/static/bin/docker-entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with this | ||
# work for additional information regarding copyright ownership. 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 | ||
# | ||
# 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. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
|
||
./bin/wait-storage.sh | ||
|
||
./bin/init-store.sh | ||
|
||
./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2023 JanusGraph Authors | ||
# | ||
# Licensed 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 | ||
# | ||
# 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. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
function abs_path() { | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [[ -h "$SOURCE" ]]; do | ||
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
done | ||
cd -P "$(dirname "$SOURCE")" && pwd | ||
} | ||
|
||
BIN=$(abs_path) | ||
TOP="$(cd "$BIN"/../ && pwd)" | ||
GRAPH_CONF="$TOP/conf/graphs/hugegraph.properties" | ||
WAIT_STORAGE_TIMEOUT_S=120 | ||
DETECT_STORAGE="$TOP/scripts/detect-storage.groovy" | ||
|
||
. "$BIN"/util.sh | ||
|
||
# apply config from env | ||
while IFS=' ' read -r envvar_key envvar_val; do | ||
if [[ "${envvar_key}" =~ hugegraph\. ]] && [[ ! -z ${envvar_val} ]]; then | ||
envvar_key=${envvar_key#"hugegraph."} | ||
if grep -q -E "^\s*${envvar_key}\s*=\.*" ${GRAPH_CONF}; then | ||
sed -ri "s#^(\s*${envvar_key}\s*=).*#\\1${envvar_val}#" ${GRAPH_CONF} | ||
else | ||
echo "${envvar_key}=${envvar_val}" >> ${GRAPH_CONF} | ||
fi | ||
else | ||
continue | ||
fi | ||
done < <(env | sort -r | awk -F= '{ st = index($0, "="); print $1 " " substr($0, st+1) }') | ||
|
||
# wait for storage | ||
if ! [ -z "${WAIT_STORAGE_TIMEOUT_S:-}" ]; then | ||
timeout "${WAIT_STORAGE_TIMEOUT_S}s" bash -c \ | ||
"until bin/gremlin-console.sh -- -e $DETECT_STORAGE > /dev/null 2>&1; do echo \"waiting for storage...\"; sleep 5; done" | ||
fi |