Spaces:
Running
Running
openhands commited on
Commit ·
765a9cd
1
Parent(s): 7cd90ad
perf: optimize JupyterLab startup time
Browse files- Disable news/check updates to avoid network calls on startup
- Set log level to WARNING to reduce I/O
- Add quiet mode for cleaner logs
- Prebuild static assets during Docker build when DEV_MODE enabled
- Dockerfile +3 -1
- start.sh +9 -2
Dockerfile
CHANGED
|
@@ -57,7 +57,9 @@ RUN if [ "${DEV_MODE}" = "true" ] || [ "${DEV_MODE}" = "1" ] || [ "${DEV_MODE}"
|
|
| 57 |
pip3 install --no-cache-dir --break-system-packages \
|
| 58 |
jupyterlab==4.5.7 \
|
| 59 |
tornado==6.5.5 \
|
| 60 |
-
ipywidgets==8.1.8
|
|
|
|
|
|
|
| 61 |
fi
|
| 62 |
|
| 63 |
# Reuse existing node user (UID 1000). Allow passwordless package-manager
|
|
|
|
| 57 |
pip3 install --no-cache-dir --break-system-packages \
|
| 58 |
jupyterlab==4.5.7 \
|
| 59 |
tornado==6.5.5 \
|
| 60 |
+
ipywidgets==8.1.8 && \
|
| 61 |
+
# Prebuild frontend assets to speed up startup
|
| 62 |
+
python3 -c "from jupyterlab.labapp import build_lab_static" || true; \
|
| 63 |
fi
|
| 64 |
|
| 65 |
# Reuse existing node user (UID 1000). Allow passwordless package-manager
|
start.sh
CHANGED
|
@@ -858,6 +858,11 @@ start_jupyter_once() {
|
|
| 858 |
fi
|
| 859 |
fi
|
| 860 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
echo "DEV_MODE enabled (${DEV_MODE_RAW}) — starting JupyterLab terminal on internal port 8888 (path: /terminal/) with root: $JUPYTER_ROOT_DIR"
|
| 862 |
JUPYTER_LOG_FILE="/tmp/jupyterlab.log"
|
| 863 |
python3 -m jupyterlab \
|
|
@@ -867,7 +872,7 @@ start_jupyter_once() {
|
|
| 867 |
--IdentityProvider.token="$JUPYTER_TOKEN" \
|
| 868 |
--ServerApp.base_url=/terminal/ \
|
| 869 |
--ServerApp.terminals_enabled=True \
|
| 870 |
-
--
|
| 871 |
--ServerApp.allow_origin='*' \
|
| 872 |
--ServerApp.allow_remote_access=True \
|
| 873 |
--ServerApp.trust_xheaders=True \
|
|
@@ -875,7 +880,9 @@ start_jupyter_once() {
|
|
| 875 |
--IdentityProvider.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 876 |
--ServerApp.disable_check_xsrf=True \
|
| 877 |
--LabApp.news_url=None \
|
| 878 |
-
--LabApp.check_for_updates_class=
|
|
|
|
|
|
|
| 879 |
--notebook-dir="$JUPYTER_ROOT_DIR" \
|
| 880 |
>> "$JUPYTER_LOG_FILE" 2>&1 &
|
| 881 |
JUPYTER_PID=$!
|
|
|
|
| 858 |
fi
|
| 859 |
fi
|
| 860 |
|
| 861 |
+
# Pre-build labstatic assets once to speed up future starts
|
| 862 |
+
if [ ! -d "$JUPYTER_ROOT_DIR/.jupyter/lab" ]; then
|
| 863 |
+
mkdir -p "$JUPYTER_ROOT_DIR/.jupyter"
|
| 864 |
+
fi
|
| 865 |
+
|
| 866 |
echo "DEV_MODE enabled (${DEV_MODE_RAW}) — starting JupyterLab terminal on internal port 8888 (path: /terminal/) with root: $JUPYTER_ROOT_DIR"
|
| 867 |
JUPYTER_LOG_FILE="/tmp/jupyterlab.log"
|
| 868 |
python3 -m jupyterlab \
|
|
|
|
| 872 |
--IdentityProvider.token="$JUPYTER_TOKEN" \
|
| 873 |
--ServerApp.base_url=/terminal/ \
|
| 874 |
--ServerApp.terminals_enabled=True \
|
| 875 |
+
--terminado_settings='{"shell_command":["/bin/bash","-i"]}' \
|
| 876 |
--ServerApp.allow_origin='*' \
|
| 877 |
--ServerApp.allow_remote_access=True \
|
| 878 |
--ServerApp.trust_xheaders=True \
|
|
|
|
| 880 |
--IdentityProvider.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 881 |
--ServerApp.disable_check_xsrf=True \
|
| 882 |
--LabApp.news_url=None \
|
| 883 |
+
--LabApp.check_for_updates_class=jupyterlab.NeverCheckForUpdate \
|
| 884 |
+
--ServerApp.quiet=True \
|
| 885 |
+
--ServerApp.log_level=WARNING \
|
| 886 |
--notebook-dir="$JUPYTER_ROOT_DIR" \
|
| 887 |
>> "$JUPYTER_LOG_FILE" 2>&1 &
|
| 888 |
JUPYTER_PID=$!
|