MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / setup_docker

Function setup_docker

src/codegraphcontext/cli/setup_wizard.py:960–1119  ·  view source on GitHub ↗

Creates Docker files and runs docker-compose for Neo4j.

()

Source from the content-addressed store, hash-verified

958 setup_local_binary()
959
960def setup_docker():
961 """Creates Docker files and runs docker-compose for Neo4j."""
962 console.print("\n[bold cyan]Setting up Neo4j with Docker...[/bold cyan]")
963
964 # Prompt for password first
965 console.print("Please set a secure password for your Neo4j database:")
966 password_questions = [
967 {"type": "password", "message": "Enter Neo4j password:", "name": "password"},
968 {"type": "password", "message": "Confirm password:", "name": "password_confirm"},
969 ]
970
971 while True:
972 passwords = prompt(password_questions)
973 if not passwords:
974 return # User cancelled
975
976 password = passwords.get("password", "")
977 if password and password == passwords.get("password_confirm"):
978 break
979 console.print("[red]Passwords do not match or are empty. Please try again.[/red]")
980
981 # Create data directories
982 neo4j_dir = Path.cwd() / "neo4j_data"
983 for subdir in ["data", "logs", "conf", "plugins"]:
984 (neo4j_dir / subdir).mkdir(parents=True, exist_ok=True)
985
986 # Fixed docker-compose.yml content
987 docker_compose_content = f"""
988services:
989 neo4j:
990 image: neo4j:5.21
991 container_name: neo4j-cgc
992 restart: unless-stopped
993 ports:
994 - "7474:7474"
995 - "7687:7687"
996 environment:
997 - NEO4J_AUTH=neo4j/{password}
998 - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
999 volumes:
1000 - neo4j_data:/data
1001 - neo4j_logs:/logs
1002
1003volumes:
1004 neo4j_data:
1005 neo4j_logs:
1006"""
1007
1008 # Write docker-compose.yml
1009 compose_file = Path.cwd() / "docker-compose.yml"
1010 with open(compose_file, "w") as f:
1011 f.write(docker_compose_content)
1012
1013 console.print("[green]✅ docker-compose.yml created with secure password.[/green]")
1014
1015 # Validate configuration format before attempting Docker operations
1016 console.print("\n[cyan]🔍 Validating configuration...[/cyan]")
1017 from codegraphcontext.core.database import DatabaseManager

Callers 1

setup_local_dbFunction · 0.85

Calls 6

run_commandFunction · 0.85
_save_neo4j_credentialsFunction · 0.85
printMethod · 0.80
getMethod · 0.65
validate_configMethod · 0.45
test_connectionMethod · 0.45

Tested by

no test coverage detected