3636 fi
3737
3838 echo " Stopping any running Apple 'container' processes..."
39+ container system stop 2> /dev/null || true
3940else
4041 echo " Apple 'container' tool not detected. Proceeding with installation..."
4142
4748 sudo installer -pkg container-installer.pkg -target /
4849fi
4950
50- echo " Starting the Sandbox Container..."
51- container system start
51+ # Stop any existing container system to clean up stale connections
52+ echo " Stopping any existing container system..."
53+ container system stop 2> /dev/null || true
54+
55+ # Wait a moment for cleanup
56+ sleep 2
57+
58+ # Start the container system (this is blocking and will wait for kernel download if needed)
59+ echo " Starting the Sandbox Container system (this may take a few minutes if downloading kernel)..."
60+ if ! container system start; then
61+ echo " ❌ Failed to start container system."
62+ exit 1
63+ fi
64+
65+ # Quick verification that system is ready
66+ echo " Verifying container system is ready..."
67+ if container system status & > /dev/null; then
68+ echo " ✅ Container system is ready."
69+ else
70+ echo " ❌ Container system started but status check failed."
71+ echo " Try running: container system stop && container system start"
72+ exit 1
73+ fi
5274
5375echo " Setting up local network domain..."
5476
5577# Run the commands for setting up the local network
5678echo " Running: sudo container system dns create local"
57- sudo container system dns create local
79+ sudo container system dns create local 2> /dev/null || echo " DNS domain 'local' already exists (this is fine) "
5880
59- echo " Running: container system dns default set local"
81+ echo " Running: container system property set dns.domain local"
6082container system property set dns.domain local
6183
62- echo " Starting the Sandbox Container..."
63- container system start
64-
6584
6685echo " Pulling the latest image: instavm/coderunner"
67- container image pull instavm/coderunner
86+ if ! container image pull instavm/coderunner; then
87+ echo " ❌ Failed to pull image. Please check your internet connection and try again."
88+ exit 1
89+ fi
6890
6991echo " → Ensuring coderunner assets directories…"
7092ASSETS_SRC=" $HOME /.coderunner/assets"
7193mkdir -p " $ASSETS_SRC /skills/user"
7294mkdir -p " $ASSETS_SRC /outputs"
7395
96+ # Stop any existing coderunner container
97+ echo " Stopping any existing coderunner container..."
98+ container stop coderunner 2> /dev/null || true
99+ sleep 2
100+
74101# Run the command to start the sandbox container
75102echo " Running: container run --name coderunner --detach --rm --cpus 8 --memory 4g instavm/coderunner"
76- container run \
103+ if container run \
77104 --volume " $ASSETS_SRC /skills/user:/app/uploads/skills/user" \
78105 --volume " $ASSETS_SRC /outputs:/app/uploads/outputs" \
79106 --name coderunner \
80107 --detach \
81108 --rm \
82109 --cpus 8 \
83110 --memory 4g \
84- instavm/coderunner
85-
86- echo " ✅ Setup complete. MCP server is available at http://coderunner.local:8222/mcp"
111+ instavm/coderunner; then
112+ echo " ✅ Setup complete. MCP server is available at http://coderunner.local:8222/mcp"
113+ else
114+ echo " ❌ Failed to start coderunner container. Please check the logs with: container logs coderunner"
115+ exit 1
116+ fi
0 commit comments