Neo4J Docker-compose Loading CSV data at startup

Published

I am trying to write a small python web service that calls a Neo4J database. This is purely in a development environment. I would like to load some CSV data when the Neo4J container starts.

I have tried using the EXTENSION_SCRIPT environment setting to load data with a script like

#!/bin/bash

load()
{
    echo "Loading data"
    neo4j-admin import --nodes=/var/lib/neo4j/import/test.csv
}

load

I keep getting errors of the following form WARNING Import failed. The store files in /data/databases/neo4j are left as they are, although they are likely in an unusable state

I am assuming that the load needs to happen before neo4j is started as there is some lock on the db files. Has anyone solved this problem ?

My Docker-compose is as follows:

neo4j:
    build: ./graph
    restart: unless-stopped
    ports: 
      - 7474:7474
      - 7687:7687
    volumes:
      - ./conf:/conf
      - ./data:/data
      - ./import:/import
      - ./logs:/logs
      - ./plugins:/plugins
    environment: 
      # Raise memory limits
      - NEO4J_dbms_memory_pagecache_size=1G
      - NEO4J_dbms.memory.heap.initial_size=1G
      - NEO4J_dbms_memory_heap_max__size=1G

And my Dockerfile :

FROM neo4j:latest

WORKDIR /

COPY load.sh /load.sh
RUN chmod +x /load.sh

ENV EXTENSION_SCRIPT=load.sh

COPY test.csv /var/lib/neo4j/import/test.csv

Source: Docker Questions

Published
Categorised as csv, docker, docker-compose, import, neo4j Tagged , , , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq