#!/bin/bash

# Define environment variables
NEO4J_VERSION="4.4.12"  # Specify the Neo4j version you want to use
CONTAINER_NAME="neo4j_container"
NEO4J_DATA_DIR="./neo4j_data"  # Local directory for Neo4j data
NEO4J_IMPORT_DIR="./neo4j_import"  # Local directory for import files
NEO4J_PASSWORD="password"  # Set a password for the Neo4j admin user

# Create local directories if they do not exist
mkdir -p "$NEO4J_DATA_DIR" "$NEO4J_IMPORT_DIR"

# Pull the Neo4j Docker image
echo "Pulling Neo4j version $NEO4J_VERSION..."
docker pull neo4j:$NEO4J_VERSION

# Run the Neo4j container
echo "Starting Neo4j container..."
docker run \
    --name $CONTAINER_NAME \
    -d \
    -p 7474:7474 -p 7687:7687 \
    -v "$NEO4J_DATA_DIR:/data" \
    -v "$NEO4J_IMPORT_DIR:/import" \
    -e NEO4J_AUTH=neo4j/$NEO4J_PASSWORD \
    -e NEO4JLABS_PLUGINS='["apoc"]' \
    -e NEO4J_dbms_security_procedures_unrestricted="apoc.*" \
    --restart unless-stopped \
    neo4j:$NEO4J_VERSION

echo "Neo4j is now running."
echo "Access it at http://localhost:7474 with username 'neo4j' and your specified password."

# what is username and password for neo4j
# username: neo4j
# password: password