Last active
January 19, 2022 08:43
-
-
Save marcingolenia/f9043d71de8e8111c10f841b131cd693 to your computer and use it in GitHub Desktop.
Neo4j in docker
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
version: '3.8' | |
services: | |
neo: | |
build: . | |
ports: | |
- 7474:7474 | |
- 7687:7687 | |
environment: | |
NEO4J_AUTH: neo4j/nRx5dFk2Z3jB3gY | |
NEO4J_USERNAME: neo4j | |
NEO4J_PASSWORD: nRx5dFk2Z3jB3gY |
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
FROM neo4j:latest | |
COPY neo_import.sh neo_import.sh | |
COPY *.cypher . | |
RUN ["chmod", "+x", "neo_import.sh"] | |
ENTRYPOINT ["./neo_import.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
#!/bin/bash | |
# Enable bash job control | |
set -m | |
# Start the primary process and put it in the background | |
/docker-entrypoint.sh neo4j & | |
# Wait for Neo4j | |
wget --quiet --tries=10 --waitretry=2 -O /dev/null http://localhost:7474 | |
# Run scripts | |
for f in *.cypher; do | |
echo "running cypher ${f}" | |
cypher-shell --file $f | |
done | |
cypher-shell --format plain "MATCH (n) RETURN count(n) AS count" | |
# Return to main process | |
fg %1 |
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
// first clear out everything preexisting | |
MATCH (n) DETACH DELETE (n); | |
// create data | |
CREATE | |
(:User {id: 'gogo@gmail.com', first_name: 'Stefen', last_name: 'Heller', address_line_1: '200 Alley Drive', address_line_2: '', city: 'Warsaw', mobile_phone: '314-694-1000'}); | |
CREATE | |
(:Portal {name: 'poland', country: 'PL', persona: '*', brand: 'xml', portalUrl: 'xml.pl', status: 'active' }); | |
// create relations | |
MATCH (u:User {id: 'gogo@gmail.com'}), (p:Portal {name: 'poland'}) | |
CREATE (u)-[:IS_PORTAL_MEMBER {id: '100', status: 'active', createdDate: '2021-11-11T11:00:00'}] -> (p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment