From 521a0fc66fe679cc7ad28cace272cfc1d663204c Mon Sep 17 00:00:00 2001 From: dekun Date: Sun, 28 Jun 2026 12:50:06 +0800 Subject: [PATCH] Remove built-in proxy from deploy scripts and show pip install progress. Proxy is optional via manual env vars only; update.sh also drops quiet pip/npm flags. Co-authored-by: Cursor --- deploy/install.sh | 14 +++++++++----- deploy/update.sh | 9 ++++++--- docs/DEPLOY.md | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/deploy/install.sh b/deploy/install.sh index a43b055..36816bf 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -11,6 +11,8 @@ WEB_PORT="${WEB_PORT:-23566}" API_PORT="${API_PORT:-8000}" BRANCH="${BRANCH:-main}" NODE_MAJOR="${NODE_MAJOR:-20}" +PIP_MIRROR="${PIP_MIRROR:-https://pypi.tuna.tsinghua.edu.cn/simple}" +NPM_REGISTRY="${NPM_REGISTRY:-https://registry.npmmirror.com}" RED='\033[0;31m' GREEN='\033[0;32m' @@ -144,27 +146,29 @@ setup_postgresql() { } setup_backend() { - log_info "安装 Python 依赖…" + log_info "安装 Python 依赖(显示完整进度,Paddle 包较大,约 10–30 分钟)…" cd "${INSTALL_DIR}/backend" python3 -m venv venv # shellcheck disable=SC1091 source venv/bin/activate - pip install --upgrade pip -q - pip install -r requirements.txt -q + pip install --upgrade pip --progress-bar on -i "${PIP_MIRROR}" + pip install -r requirements.txt --progress-bar on -i "${PIP_MIRROR}" deactivate } setup_frontend() { log_info "构建前端…" cd "${INSTALL_DIR}/frontend" - npm ci --silent + npm config set registry "${NPM_REGISTRY}" + npm ci npm run build } setup_gateway() { log_info "安装 Web 网关依赖…" cd "${INSTALL_DIR}/deploy/pm2" - npm ci --silent + npm config set registry "${NPM_REGISTRY}" + npm ci } start_pm2() { diff --git a/deploy/update.sh b/deploy/update.sh index 7d38c6c..529a306 100644 --- a/deploy/update.sh +++ b/deploy/update.sh @@ -3,6 +3,8 @@ set -euo pipefail INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}" BRANCH="${BRANCH:-main}" +PIP_MIRROR="${PIP_MIRROR:-https://pypi.tuna.tsinghua.edu.cn/simple}" +NPM_REGISTRY="${NPM_REGISTRY:-https://registry.npmmirror.com}" GREEN='\033[0;32m' NC='\033[0m' @@ -19,17 +21,18 @@ git pull origin "${BRANCH}" log_info "更新后端依赖…" cd backend source venv/bin/activate -pip install -r requirements.txt -q +pip install -r requirements.txt --progress-bar on -i "${PIP_MIRROR}" deactivate log_info "重建前端…" cd ../frontend -npm ci --silent +npm config set registry "${NPM_REGISTRY}" +npm ci npm run build log_info "更新网关…" cd ../deploy/pm2 -npm ci --silent +npm ci log_info "重启 PM2…" cd "${INSTALL_DIR}" diff --git a/docs/DEPLOY.md b/docs/DEPLOY.md index 6b334d3..d78484b 100644 --- a/docs/DEPLOY.md +++ b/docs/DEPLOY.md @@ -145,8 +145,25 @@ ufw enable ```bash WEB_PORT=23566 INSTALL_DIR=/opt/secondary-school-grade-archive bash deploy/install.sh + +# 使用官方 PyPI(海外服务器可去掉国内镜像) +PIP_MIRROR=https://pypi.org/simple bash deploy/install.sh ``` +### 网络代理(可选,脚本内不内置) + +一键部署**不会**自动配置代理。无代理环境可直接运行,不会因代理报错。 + +若本机网络需走代理,请在**执行安装前**手动 export(仅当前终端生效): + +```bash +export HTTP_PROXY=http://你的代理地址:端口 +export HTTPS_PROXY=http://你的代理地址:端口 +bash deploy/install.sh +``` + +不设置则不走代理。`pip install` 会**显示完整下载/安装进度**,不再静默。 + --- ## 11. 版权