summaryrefslogtreecommitdiff
path: root/scripts/start_sandbox.sh
diff options
context:
space:
mode:
authorOlcan <[email protected]>2025-04-24 08:58:47 -0700
committerGitHub <[email protected]>2025-04-24 08:58:47 -0700
commit30bdef9bf54ec3215026643fea957334eb5c00ae (patch)
tree4cd77967961c6411ba673d5ac52babdbb97ce5f9 /scripts/start_sandbox.sh
parentfb1c67219d3bfb9d4193b4f9c0c60e2969657132 (diff)
in sandboxed run scripts, allow .env to be an in any ancestor directory, same as in findEnvFile; also prep for sanboxing with global command (#147)
Diffstat (limited to 'scripts/start_sandbox.sh')
-rwxr-xr-xscripts/start_sandbox.sh25
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/start_sandbox.sh b/scripts/start_sandbox.sh
index ac8fe6e7..2146a0c8 100755
--- a/scripts/start_sandbox.sh
+++ b/scripts/start_sandbox.sh
@@ -42,16 +42,27 @@ while $CMD ps -a --format "{{.Names}}" | grep -q "$IMAGE-$INDEX"; do
done
run_args+=(--name "$IMAGE-$INDEX" --hostname "$IMAGE-$INDEX")
-# also set SANDBOX environment variable as container name
-run_args+=(--env "SANDBOX=$IMAGE-$INDEX")
+# if .env exists, source it before variable existence checks below
+# allow .env to be in any ancestor directory (same as findEnvFile in config.ts)
+current_dir=$(pwd)
+while [ "$current_dir" != "/" ]; do
+ if [ -f "$current_dir/.env" ]; then
+ source "$current_dir/.env"
+ break
+ fi
+ current_dir=$(dirname "$current_dir")
+done
+
+# if GEMINI_API_KEY is set, copy into container
+if [ -n "${GEMINI_API_KEY:-}" ]; then run_args+=(--env GEMINI_API_KEY="$GEMINI_API_KEY"); fi
# pass TERM and COLORTERM to container to maintain terminal colors
-run_args+=(--env TERM --env COLORTERM)
+if [ -n "${TERM:-}" ]; then run_args+=(--env TERM="$TERM"); fi
+if [ -n "${COLORTERM:-}" ]; then run_args+=(--env COLORTERM="$COLORTERM"); fi
-# set GEMINI_API_KEY environment variable if it exists
-if [ -n "${GEMINI_API_KEY:-}" ]; then
- run_args+=(--env GEMINI_API_KEY)
-fi
+# set SANDBOX environment variable as container name
+# this is the preferred mechanism to detect if inside container/sandbox
+run_args+=(--env "SANDBOX=$IMAGE-$INDEX")
# enable debugging via node --inspect-brk (and $DEBUG_PORT) if DEBUG is set
node_args=()