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 <cursoragent@cursor.com>
This commit is contained in:
@@ -94,4 +94,5 @@ docker run --rm -it \
|
||||
- `GIT_REPO_URL`:容器启动时拉取代码的仓库地址
|
||||
- `GIT_BRANCH`:拉取分支(默认 `main`)
|
||||
- `WORKTREE_DIR`:容器内代码目录(默认 `/app/runtime`)
|
||||
- `NPM_REGISTRY`:前端依赖安装镜像源(默认 `https://registry.npmmirror.com`)
|
||||
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user