diff options
| author | Olcan <[email protected]> | 2025-04-28 18:40:24 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-28 18:40:24 -0700 |
| commit | 0d849bf58effd00e72a6a169bda8adc120086ac7 (patch) | |
| tree | 2f20863051bb4c8f7a4ca61e581e7b00ca475235 /scripts/start_sandbox.sh | |
| parent | 3073c67861806a5312f5a7fa4c1c091507bd4755 (diff) | |
enable servers in sandbox to listen on localhost (127.0.0.1) instead of 0.0.0.0, ensuring servers can be container/host-agnostic (#207)
* enable servers in sandbox to listen on localhost (127.0.0.1) instead of 0.0.0.0, ensuring servers can be container/host-agnostic
* Merge remote-tracking branch 'origin/main' into sandbox_localhost_works
Diffstat (limited to 'scripts/start_sandbox.sh')
| -rwxr-xr-x | scripts/start_sandbox.sh | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/start_sandbox.sh b/scripts/start_sandbox.sh index 67c9cf27..444efbd3 100755 --- a/scripts/start_sandbox.sh +++ b/scripts/start_sandbox.sh @@ -135,20 +135,24 @@ fi node_args+=("$CLI_PATH" "$@") # open additional ports if SANDBOX_PORTS is set +# also set up redirects (via socat) so servers can listen on localhost instead of 0.0.0.0 +bash_cmd="" if [ -n "${SANDBOX_PORTS:-}" ]; then ports=$(echo "$SANDBOX_PORTS" | tr ',' '\n') for port in $ports; do if [ -n "$port" ]; then echo "SANDBOX_PORTS: $port" run_args+=(-p "$port:$port") + bash_cmd+="socat TCP4-LISTEN:$port,bind=\$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:$port 2> /dev/null& " fi done fi +bash_cmd+="node $(printf '%q ' "${node_args[@]}")" # printf fixes quoting within args # run gemini-code in sandbox container if [[ "$CMD" == "podman" ]]; then # use empty --authfile to skip unnecessary auth refresh overhead - $CMD run "${run_args[@]}" --authfile <(echo '{}') "$IMAGE" node "${node_args[@]}" + $CMD run "${run_args[@]}" --authfile <(echo '{}') "$IMAGE" bash -c "$bash_cmd" else - $CMD run "${run_args[@]}" "$IMAGE" node "${node_args[@]}" + $CMD run "${run_args[@]}" "$IMAGE" bash -c "$bash_cmd" fi |
