Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-01-2020 02:06 AM
I'm looking for some advice regarding best practices for populating a database upon initial build of a docker container. I have a docker-compose file that launches an instance of neo4j-4.2.0-community, alongside a python application that will be interacting with the database. I have a cypher script, and a csv file, that together populate the db with appropriate test data. My question is then:
What is the recommended way to store/execute the script/csv file such that it is of least encumbrance to collaborators? That is, ideally I don't need to tell them to find the csv file in version control and paste it into the neo4j browser prompt. I also don't want to track the database in version control.
As side note that may or may not be relevant; I noticed that in neo4j browser there is a tab for local scripts Is there a way I can mount this as a volume so that when a collaborator creates the containers, they can simply click on the saved script to populate the db? That would be sufficient and actually preferable to having the script run directly upon startup or something similar.
Any and all help is much appreciated and please let me know if you want further information.
12-14-2020 03:25 PM
You can add the "bootstrapping" cypher script and shell script to execute the cypher into git, then use "ADD" in docker to get the files.
At the end of the Dockerfile, use "RUN" to execute the cypher-shell loading scripts. (use -f parameter)
Alternatively you can used Build ( populate DB) and Deploy docker-compose files for DevOps orchestrations.
01-18-2021 11:20 AM
Oh I didn't know that was possible - but that's cool.
Do you have an example Dockerfile
and/or docker-compose.yml
snippet I could refer to?
01-18-2021 06:24 PM
Just to round out the thread, I'm sharing my solution of how to accomplish this
Example docker-compose.yml
- heimdall/docker-compose.yml at main · TheRobBrennan/heimdall · GitHub
Example Dockerfile
with a wrapper.sh
script that handles importing data - heimdall/neo4j/v4.x.x at main · TheRobBrennan/heimdall · GitHub
Example Cypher script that is used to create seed data for nodes and relationships - as well as defining constraints - heimdall/neo4j at main · TheRobBrennan/heimdall · GitHubseed
01-23-2021 04:43 PM
Hi @therobbrennan , apologies for the delay. here is my blog as an example.
http://www.dominickumar.com/blog/neo4j-seed-docker-with-data/
01-23-2021 05:00 PM
That's so awesome. Thank you for sharing ::fist bump::
All the sessions of the conference are now available online