-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Siddharth Golecha <[email protected]> Signed-off-by: Oleksandr Porunov <[email protected]>
- Loading branch information
Showing
5 changed files
with
151 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GREMLIN_HOST=janusgraph | ||
GREMLIN_PORT=8182 |
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,61 @@ | ||
services: | ||
janusgraph: | ||
image: docker.io/janusgraph/janusgraph:latest | ||
container_name: janusgraph | ||
networks: | ||
- janus_bridge | ||
ports: | ||
- "8182:8182" | ||
healthcheck: | ||
test: ["CMD", "./bin/gremlin.sh", "-e", "scripts/remote-connect.groovy"] | ||
interval: 5s | ||
timeout: 10s | ||
retries: 20 | ||
start_period: 5s | ||
volumes: | ||
- "janusgraph-data:/var/lib/janusgraph" | ||
|
||
gremlin-console: | ||
image: docker.io/janusgraph/janusgraph:latest | ||
container_name: gremlin-console | ||
networks: | ||
- janus_bridge | ||
depends_on: | ||
janusgraph: | ||
condition: service_healthy | ||
env_file: | ||
- .env | ||
entrypoint: > | ||
bash -c " | ||
./bin/gremlin.sh -e /scripts/load_gods_script.groovy | ||
" | ||
volumes: | ||
- ./scripts:/scripts | ||
|
||
janusgraph-visualizer: | ||
build: | ||
context: . | ||
dockerfile: full.Dockerfile | ||
image: docker.io/janusgraph/janusgraph-visualizer | ||
container_name: janusgraph-visualizer | ||
depends_on: | ||
gremlin-console: | ||
condition: service_completed_successfully | ||
janusgraph: | ||
condition: service_healthy | ||
ports: | ||
- "3001:3001" | ||
- "3000:3000" | ||
networks: | ||
- janus_bridge | ||
env_file: | ||
- .env | ||
environment: | ||
NODE_ENV: production | ||
|
||
networks: | ||
janus_bridge: | ||
driver: bridge | ||
volumes: | ||
janusgraph-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,39 @@ | ||
#### Setting up with Docker (without docker-compose usage) | ||
|
||
You can build a Docker image of the JanusGraph visualizer with the included `Dockerfile`. | ||
This will use the current version of the `main` branch of the source GitHub repository. | ||
The Docker image can be built by calling the `docker build -f full.Dockerfile` command, for example: | ||
|
||
```sh | ||
docker build --tag=janusgraph-visualizer:latest -f full.Dockerfile . | ||
``` | ||
|
||
If you had already built node project on your host then you can create a Docker image faster by using `Dockerfile` instead of `full.Dockerfile`: | ||
|
||
```sh | ||
docker build --tag=janusgraph-visualizer:latest . | ||
``` | ||
|
||
The image can also be downloaded from Docker hub: [`janusgraph/janusgraph-visualizer:latest`](https://hub.docker.com/r/janusgraph/janusgraph-visualizer). | ||
|
||
```sh | ||
docker pull janusgraph/janusgraph-visualizer:latest | ||
``` | ||
|
||
The Docker image can then be run by calling `docker run` and exposing the necessary ports for communication. See [Docker's documentation](https://docs.docker.com/engine/reference/commandline/run/) for more options on how to run the image. | ||
|
||
```sh | ||
# if you built the image yourself | ||
docker run --rm -d -p 3000:3000 -p 3001:3001 --name=janusgraph-visualizer --network=host janusgraph-visualizer:latest | ||
# if you downloaded from Docker Hub | ||
docker run --rm -d -p 3000:3000 -p 3001:3001 --name=janusgraph-visualizer --network=host janusgraph/janusgraph-visualizer:latest | ||
``` | ||
Note that `--network=host` is not needed if you don't run your gremlin server in the host machine. | ||
|
||
* Open the browser and navigate to | ||
```sh | ||
http://localhost:3001 | ||
``` | ||
|
||
The Docker container can be stopped by calling `docker stop janusgraph-visualizer`. | ||
|
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,38 @@ | ||
def runScript() { | ||
import org.apache.tinkerpop.gremlin.driver.Client | ||
import org.apache.tinkerpop.gremlin.driver.Cluster | ||
|
||
def environmentVariables = System.getenv(); | ||
def gremlinHost = environmentVariables['GREMLIN_HOST'] ?: 'localhost' | ||
def gremlinPort = environmentVariables['GREMLIN_PORT'] ?: '8182' | ||
|
||
println "Connecting to Gremlin Server at $gremlinHost:$gremlinPort" | ||
|
||
Cluster cluster = Cluster.build(gremlinHost).port(Integer.parseInt(gremlinPort)).create() | ||
Client client = cluster.connect() | ||
|
||
// Fetch vertex count - returns List<Result> | ||
def results = client.submit('g.V().count()').all().get() | ||
if (results.isEmpty()) { | ||
throw new RuntimeException("Failed to retrieve vertex count.") | ||
} | ||
|
||
// Extract the value from the Result object | ||
def vertexCount = results[0].getLong() // getLong() converts the underlying number to a Long | ||
println "Vertex count: $vertexCount" | ||
|
||
// Load the graph only if it's empty | ||
if (vertexCount == 0) { | ||
println "Loading the graph as it's empty..." | ||
client.submit('GraphOfTheGodsFactory.load(graph)').all().get() | ||
println "Data loaded successfully!" | ||
} else { | ||
println "Graph already contains data. Skipping load." | ||
} | ||
|
||
// Close the connection | ||
client.close() | ||
cluster.close() | ||
} | ||
|
||
runScript() |