From 78a4932526efc05bd9741b89eccd34a0c044421d Mon Sep 17 00:00:00 2001 From: renjue Date: Sat, 9 May 2026 17:00:56 +0800 Subject: [PATCH] Improve Docker startup npm install speed and observability. Use configurable npm mirror with npm ci --no-audit --no-fund and add startup logs plus README docs for NPM_REGISTRY. Co-authored-by: Cursor --- README.md | 1 + docker/start.sh | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db86574..777f18b 100644 --- a/README.md +++ b/README.md @@ -94,4 +94,5 @@ docker run --rm -it \ - `GIT_REPO_URL`:容器启动时拉取代码的仓库地址 - `GIT_BRANCH`:拉取分支(默认 `main`) - `WORKTREE_DIR`:容器内代码目录(默认 `/app/runtime`) +- `NPM_REGISTRY`:前端依赖安装镜像源(默认 `https://registry.npmmirror.com`) diff --git a/docker/start.sh b/docker/start.sh index 86a5d2a..bb18f06 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -6,6 +6,7 @@ GIT_BRANCH="${GIT_BRANCH:-main}" WORKTREE_DIR="${WORKTREE_DIR:-/app/runtime}" BACKEND_PORT="${FLASK_RUN_PORT:-14620}" FRONTEND_PORT="${FRONTEND_PORT:-14621}" +NPM_REGISTRY="${NPM_REGISTRY:-https://registry.npmmirror.com}" echo "[start] syncing source from ${GIT_REPO_URL} (${GIT_BRANCH})" if [ ! -d "${WORKTREE_DIR}/.git" ]; then @@ -26,7 +27,10 @@ fi echo "[start] installing frontend dependencies and building" cd "${WORKTREE_DIR}/frontend" -npm install +echo "[start] npm registry: ${NPM_REGISTRY}" +npm config set registry "${NPM_REGISTRY}" +npm ci --no-audit --no-fund +echo "[start] building frontend assets" npm run build echo "[start] launching backend:${BACKEND_PORT} and frontend:${FRONTEND_PORT}"