fix(api): keep unconfigured services running and preserve Docker onboarding
This commit is contained in:
1 parent
e20737a509
commit
de8fbc3ad2
13 files changed
+133
-63
No files matched your search
+19
-19
@@ -1,24 +1,6 @@
|
||||
#!/bin/sh
|
||||
dir="$HOME/.nanobot"
|
||||
|
||||
# Render keeps environment references in its deployment template. Local
|
||||
# Compose generates and validates its initial config through Python instead.
|
||||
if [ "$RENDER" = "true" ]; then
|
||||
config="$dir/config.json"
|
||||
mkdir -p "$dir" || exit 1
|
||||
if [ ! -f "$config" ]; then
|
||||
echo "[entrypoint] initializing $config from render-config.json"
|
||||
cp /app/render-config.json "$config" || exit 1
|
||||
else
|
||||
echo "[entrypoint] existing $config found — leaving it in place"
|
||||
fi
|
||||
set -- "$@" --config "$config"
|
||||
elif [ "$NANOBOT_DOCKER_BOOTSTRAP" = "1" ]; then
|
||||
config="$dir/config.json"
|
||||
python -m nanobot.cli.docker_bootstrap "$config" || exit 1
|
||||
set -- "$@" --config "$config"
|
||||
fi
|
||||
|
||||
# Drop privileges whenever the container starts as root. Render mounts the
|
||||
# persistent disk root-owned, and a plain `docker run` also defaults to root now,
|
||||
# so this covers both. Chown the data dir so the non-root user can write it, then
|
||||
@@ -28,7 +10,7 @@ if [ "$(id -u)" = "0" ]; then
|
||||
chown -R nanobot:nanobot "$dir" 2>/dev/null || echo "[entrypoint] warning: chown $dir failed"
|
||||
if setpriv --reuid=nanobot --regid=nanobot --init-groups true 2>/dev/null; then
|
||||
echo "[entrypoint] dropping privileges to nanobot via setpriv"
|
||||
exec setpriv --reuid=nanobot --regid=nanobot --init-groups nanobot "$@"
|
||||
exec setpriv --reuid=nanobot --regid=nanobot --init-groups "$0" "$@"
|
||||
fi
|
||||
echo "[entrypoint] error: started as root but setpriv privilege drop failed — refusing to run as root" >&2
|
||||
exit 1
|
||||
@@ -48,4 +30,22 @@ EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Render keeps environment references in its deployment template. Local
|
||||
# Compose generates and validates its initial config through Python instead.
|
||||
if [ "$RENDER" = "true" ]; then
|
||||
config="$dir/config.json"
|
||||
mkdir -p "$dir" || exit 1
|
||||
if [ ! -f "$config" ]; then
|
||||
echo "[entrypoint] initializing $config from render-config.json"
|
||||
cp /app/render-config.json "$config" || exit 1
|
||||
else
|
||||
echo "[entrypoint] existing $config found — leaving it in place"
|
||||
fi
|
||||
set -- "$@" --config "$config"
|
||||
elif [ "$NANOBOT_DOCKER_BOOTSTRAP" = "1" ] && { [ "$1" = "gateway" ] || [ "$1" = "serve" ]; }; then
|
||||
config="$dir/config.json"
|
||||
python -m nanobot.cli.docker_bootstrap "$config" || exit 1
|
||||
set -- "$@" --config "$config"
|
||||
fi
|
||||
|
||||
exec nanobot "$@"
|
||||
Reference in new issue
Block a user