Support optional Ubuntu system bootstrap
This commit is contained in:
@@ -31,6 +31,27 @@ bash scripts/deploy-ubuntu.sh "$BRANCH" --skip-git
|
||||
'
|
||||
```
|
||||
|
||||
如果是全新 Ubuntu 机器,也可以在同一个入口中打开系统依赖初始化:
|
||||
|
||||
```bash
|
||||
BOOTSTRAP_SYSTEM=1 APP_DIR="$HOME/zk-data-agent" BRANCH="main" REPO="git@git.n.xiaomi.com:wuyang6/zk-data-agent.git" bash -lc '
|
||||
set -euo pipefail
|
||||
|
||||
if [ -d "$APP_DIR/.git" ]; then
|
||||
cd "$APP_DIR"
|
||||
git fetch origin
|
||||
git checkout "$BRANCH"
|
||||
git pull --ff-only origin "$BRANCH"
|
||||
else
|
||||
rm -rf "$APP_DIR"
|
||||
git clone --branch "$BRANCH" "$REPO" "$APP_DIR"
|
||||
cd "$APP_DIR"
|
||||
fi
|
||||
|
||||
bash scripts/deploy-ubuntu.sh "$BRANCH" --skip-git --bootstrap-system
|
||||
'
|
||||
```
|
||||
|
||||
修改部署目录或分支时,只需要调整命令开头的变量:
|
||||
|
||||
```bash
|
||||
@@ -53,6 +74,14 @@ APP_DIR="$HOME/zk-data-agent-test" BRANCH="main" REPO="git@git.n.xiaomi.com:wuya
|
||||
bash scripts/deploy-ubuntu.sh
|
||||
```
|
||||
|
||||
如果是全新 Ubuntu 机器,首次安装可以让脚本顺手安装系统依赖:
|
||||
|
||||
```bash
|
||||
bash scripts/deploy-ubuntu.sh --bootstrap-system
|
||||
```
|
||||
|
||||
`--bootstrap-system` 会使用 `sudo apt-get` 安装 Python 编译依赖、`git`、`curl` 等系统包;应用代码、`.venv`、前端依赖、运行数据和 systemd 用户服务仍然都在当前用户目录下。
|
||||
|
||||
部署指定分支:
|
||||
|
||||
```bash
|
||||
@@ -158,6 +187,8 @@ Ubuntu 部署建议准备:
|
||||
- Node.js `20` 或 `22`
|
||||
- `npm`
|
||||
|
||||
如果机器缺少 Python 编译依赖,首次执行时可加 `--bootstrap-system`,脚本会请求 sudo 安装系统包。日常部署和更新不需要 sudo。
|
||||
|
||||
Python 后端依赖由部署脚本安装到项目根目录 `.venv`。
|
||||
|
||||
前端依赖由部署脚本在 `frontend/app` 下执行 `npm ci` 安装,并执行 `npm run build`。
|
||||
|
||||
Reference in New Issue
Block a user