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

Function setup_docker

src/codegraphcontext/cli/setup_wizard.py:965–1124  ·  view source on GitHub ↗

Creates Docker files and runs docker-compose for Neo4j.

()

Source from the content-addressed store, hash-verified

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