Harden Jupyter startup token handling and runtime checks
This commit is contained in:
@@ -8,7 +8,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
COMFYUI_PORT=8188 \
|
||||
JUPYTER_PORT=8888 \
|
||||
JUPYTER_TOKEN=runpod \
|
||||
COMFYUI_WORKDIR=/workspace/ComfyUI \
|
||||
RUNPOD_VOLUME_ROOT=/workspace
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ ROOT=/opt/bootstrap/Runpod_Comfy
|
||||
WORKDIR="${COMFYUI_WORKDIR:-/workspace/ComfyUI}"
|
||||
PORT="${COMFYUI_PORT:-8188}"
|
||||
JUPYTER_PORT="${JUPYTER_PORT:-8888}"
|
||||
JUPYTER_TOKEN="${JUPYTER_TOKEN:-runpod}"
|
||||
JUPYTER_TOKEN="${JUPYTER_TOKEN:-}"
|
||||
|
||||
"$ROOT/core/scripts/bootstrap.sh"
|
||||
|
||||
@@ -17,15 +17,30 @@ if [[ -f "$LOCK" ]]; then
|
||||
fi
|
||||
|
||||
if [[ "$ENABLE_JUPYTER_LOCK" == "true" ]]; then
|
||||
echo "[jupyter] starting on 0.0.0.0:${JUPYTER_PORT}"
|
||||
jupyter lab \
|
||||
--ip=0.0.0.0 \
|
||||
--port "$JUPYTER_PORT" \
|
||||
--no-browser \
|
||||
--allow-root \
|
||||
--IdentityProvider.token="$JUPYTER_TOKEN" \
|
||||
--ServerApp.root_dir="$WORKDIR" \
|
||||
>/tmp/jupyter.log 2>&1 &
|
||||
if ! command -v jupyter >/dev/null 2>&1; then
|
||||
echo "[jupyter] WARNING: ENABLE_JUPYTER=true but jupyter binary not found (likely built with ENABLE_JUPYTER=false)"
|
||||
else
|
||||
if [[ -z "$JUPYTER_TOKEN" ]]; then
|
||||
JUPYTER_TOKEN="$(python3 -c 'import secrets; print(secrets.token_hex(16))')"
|
||||
echo "[jupyter] generated token: $JUPYTER_TOKEN"
|
||||
fi
|
||||
|
||||
echo "[jupyter] starting on 0.0.0.0:${JUPYTER_PORT}"
|
||||
jupyter lab \
|
||||
--ip=0.0.0.0 \
|
||||
--port "$JUPYTER_PORT" \
|
||||
--no-browser \
|
||||
--allow-root \
|
||||
--IdentityProvider.token="$JUPYTER_TOKEN" \
|
||||
--ServerApp.root_dir="$WORKDIR" \
|
||||
>/tmp/jupyter.log 2>&1 &
|
||||
|
||||
JUPYTER_PID=$!
|
||||
sleep 2
|
||||
if ! kill -0 "$JUPYTER_PID" 2>/dev/null; then
|
||||
echo "[jupyter] WARNING: failed to start, check /tmp/jupyter.log"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$WORKDIR"
|
||||
|
||||
@@ -33,7 +33,7 @@ docker push ${IMAGE_NAME}:${IMAGE_TAG}
|
||||
|
||||
- `COMFYUI_PORT=8188`
|
||||
- `JUPYTER_PORT=8888`
|
||||
- `JUPYTER_TOKEN=...` (default in image is `runpod`)
|
||||
- `JUPYTER_TOKEN=...` (recommended to set explicitly; if unset, container auto-generates and logs a token)
|
||||
- `COMFYUI_WORKDIR=/workspace/ComfyUI`
|
||||
- `HF_TOKEN=...` (if needed)
|
||||
- `CIVITAI_TOKEN=...` (if needed)
|
||||
|
||||
Reference in New Issue
Block a user