passwd
passwd

Reputation: 3353

Neo4J Docker Constraints

I'm trying to run a docker container with Neo4J image. Everything works great, but I need to add constraints after initialization of the container. What is the best way to do so?

I mount a file with cypher commands and trying to run it with docker-compose like this:

neo4j:
    image: neo4j:3.5.8
    container_name: neo4j
    ports:
      - "7474:7474"
      - "7687:7687"
    networks:
      - backend
    environment:
      - NEO4J_dbms_security_procedures_unrestricted=apoc.*
      - NEO4J_apoc_import_file_enabled=true
      - NEO4J_dbms_shell_enabled=true
      - NEO4J_AUTH=neo4j/password
    volumes:
      - .\lib\neo4j\plugins:/plugins
      - .\src\main\resources:/scripts
      - neo4j_data:/data
      - neo4j_import:/neo4j_import
    command: ["neo4j", "&&", "sleep 10", "&&", "cat /scripts/constraints.neo4j | cypher-shell -u neo4j -p password"]

Tried it even with

entrypoint: ""
command: "/docker-entrypoint.sh neo4j && sleep 10 && cat /scripts/constraints.neo4j | cypher-shell -u neo4j -p password"

But constraints are not being made. How to pass there my cypher commands from a file? Thanx.

Upvotes: 1

Views: 281

Answers (1)

logisima
logisima

Reputation: 7478

The easiest way to do that is to use APOC with its initializer feature : https://neo4j.com/docs/labs/apoc/current/operational/init-script/#init-script

Upvotes: 0

Related Questions