From 97cd3c43679b2d594975317cdfc236ed4e74b1e9 Mon Sep 17 00:00:00 2001 From: engigu Date: Sun, 4 Jan 2026 09:01:02 +0800 Subject: [PATCH] chore: update entrypoint.sh started speed --- docker-entrypoint.sh | 52 +++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7d9e054..10c2a2e 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -17,31 +17,43 @@ mkdir -p \ "$NODE_ENV_DIR" # ============================ -# Python 虚拟环境 +# Python 虚拟环境(后台并行) # ============================ -if [ ! -x "$PYTHON_VENV_DIR/bin/python" ]; then - echo "[entrypoint] Creating Python virtual environment..." - python3 -m venv "$PYTHON_VENV_DIR" - "$PYTHON_VENV_DIR/bin/pip" config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple - "$PYTHON_VENV_DIR/bin/pip" install --upgrade pip setuptools wheel -else - echo "[entrypoint] Python venv exists" -fi +( + if [ ! -x "$PYTHON_VENV_DIR/bin/python" ]; then + echo "[entrypoint] Creating Python virtual environment..." + python3 -m venv "$PYTHON_VENV_DIR" + "$PYTHON_VENV_DIR/bin/pip" config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + "$PYTHON_VENV_DIR/bin/pip" install --upgrade pip setuptools wheel + echo "[entrypoint] Python venv created" + else + echo "[entrypoint] Python venv exists" + fi +) & +PYTHON_PID=$! # ============================ -# Node 环境(npm prefix) +# Node 环境(后台并行) # ============================ -echo "[entrypoint] Initializing Node npm prefix..." +( + echo "[entrypoint] Initializing Node npm prefix..." + # npm 全局安装目录 → /app/envs/node + npm config set prefix "$NODE_ENV_DIR" + # npm 行为优化(防内存暴涨) + npm config set registry https://registry.npmmirror.com + npm config set audit false + npm config set fund false + npm config set progress false + npm config set maxsockets 2 + echo "[entrypoint] Node npm configured" +) & +NODE_PID=$! -# npm 全局安装目录 → /app/envs/node -npm config set prefix "$NODE_ENV_DIR" - -# npm 行为优化(防内存暴涨) -npm config set registry https://registry.npmmirror.com -npm config set audit false -npm config set fund false -npm config set progress false -npm config set maxsockets 2 +# 等待两个后台任务完成 +echo "[entrypoint] Waiting for environment initialization..." +wait $PYTHON_PID +wait $NODE_PID +echo "[entrypoint] Environment initialization completed" # Node 内存限制 export NODE_OPTIONS="--max-old-space-size=256"