Vivek
Vivek

Reputation: 13278

How to import data into janusgraph docker at startup

I want to run the janusgraph container ready with some data loaded at the time of initialisation.

I've checked the janusgraph docker documentation - https://github.com/JanusGraph/janusgraph-docker but didn't find any information around initialising the container pre loaded with data.

Is there any easy way to do this. I can write a groovy script or a java class to import the data, I just want to know how do I call this at the time of container creation so that once the container is ready it has the data pre-loaded in it.

Upvotes: 1

Views: 340

Answers (1)

Florian Hockmann
Florian Hockmann

Reputation: 2809

Maybe you missed that part of the docs but the README.md contains a section Initialization that explains how to load data into JanusGraph when the container starts.

You just need to create a Groovy script (the file name needs to end on .groovy) and put it into the /docker-entrypoint-initdb.d which lets JanusGraph execute it when the container starts.

A quick example that is taken directly from that section looks like this:

  1. Create a Groovy script and name it add-vertex-groovy:
g = traversal().withRemote('conf/remote-graph.properties')
// add the traversals to initialize the Graph with your data
g.addV('demigod').property('name', 'hercules').iterate()
  1. Put the file in the relevant directory, e.g., by creating a custom Dockerfile:
FROM janusgraph/janusgraph:0.5.2
    
COPY add-vertex-groovy /docker-entrypoint-initdb.d/

Upvotes: 3

Related Questions