diff --git a/packages/cli/src/utils/sandbox.ts b/packages/cli/src/utils/sandbox.ts index 2b672ef5..5038e702 100644 --- a/packages/cli/src/utils/sandbox.ts +++ b/packages/cli/src/utils/sandbox.ts @@ -308,9 +308,8 @@ export async function start_sandbox(sandbox: string) { console.error(`using ${projectSandboxDockerfile} for sandbox`); buildArgs += `-s -f ${path.resolve(projectSandboxDockerfile)} -i ${image}`; } - spawnSync(`cd ${gcRoot} && scripts/build_sandbox.sh ${buildArgs}`, { + execSync(`cd ${gcRoot} && scripts/build_sandbox.sh ${buildArgs}`, { stdio: 'inherit', - shell: true, env: { ...process.env, GEMINI_SANDBOX: sandbox, // in case sandbox is enabled via flags (see config.ts under cli package) diff --git a/scripts/build_sandbox.sh b/scripts/build_sandbox.sh index 4366cd45..151c8284 100755 --- a/scripts/build_sandbox.sh +++ b/scripts/build_sandbox.sh @@ -76,36 +76,26 @@ if [ -n "${VERBOSE:-}" ]; then BUILD_STDOUT="/dev/stdout" fi -# initialize build arg array from BUILD_SANDBOX_FLAGS -read -r -a build_args <<<"${BUILD_SANDBOX_FLAGS:-}" - build_image() { - local -n build_args=$1 - if [[ "$CMD" == "podman" ]]; then # use empty --authfile to skip unnecessary auth refresh overhead - $CMD build --authfile=<(echo '{}') "${build_args[@]}" >$BUILD_STDOUT + $CMD build --authfile=<(echo '{}') "$@" >$BUILD_STDOUT elif [[ "$CMD" == "docker" ]]; then - # use config directory to skip unnecessary auth refresh overhead - $CMD --config=".docker" buildx build "${build_args[@]}" >$BUILD_STDOUT + $CMD --config=".docker" buildx build "$@" >$BUILD_STDOUT else - $CMD build "${build_args[@]}" >$BUILD_STDOUT + $CMD build "$@" >$BUILD_STDOUT fi } -# build container images & prune older unused images - echo "building $BASE_IMAGE ... (can be slow first time)" -base_image_build_args=(${build_args[@]}) -base_image_build_args+=(-f "$BASE_DOCKERFILE" -t "$BASE_IMAGE" .) -build_image base_image_build_args +# shellcheck disable=SC2086 # allow globbing and word splitting for BUILD_SANDBOX_FLAGS +build_image ${BUILD_SANDBOX_FLAGS:-} -f "$BASE_DOCKERFILE" -t "$BASE_IMAGE" . echo "built $BASE_IMAGE" if [[ -n "$CUSTOM_DOCKERFILE" && -n "$CUSTOM_IMAGE" ]]; then echo "building $CUSTOM_IMAGE ... (can be slow first time)" - custom_image_build_args=(${build_args[@]}) - custom_image_build_args+=(-f "$CUSTOM_DOCKERFILE" -t "$CUSTOM_IMAGE" .) - build_image custom_image_build_args + # shellcheck disable=SC2086 # allow globbing and word splitting for BUILD_SANDBOX_FLAGS + build_image ${BUILD_SANDBOX_FLAGS:-} -f "$CUSTOM_DOCKERFILE" -t "$CUSTOM_IMAGE" . echo "built $CUSTOM_IMAGE" fi