-
Notifications
You must be signed in to change notification settings - Fork 7
Adding a docker compose for better startup #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
docker compose
is used, you can specify these values via the .env file or supplying environment variables directly to the container.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have created the
.env
file for that and thanks for adding it to the README.md. I totally forgot to mention that 😅