Skip to content

Commit 3f39432

Browse files
authored
⭐️ Add upgrade script
2 parents a559a0d + 614b366 commit 3f39432

27 files changed

+474
-124
lines changed

doc/docs/en/deployment/upgrade-guide.md

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,62 @@
22

33
## 🚀 Upgrade Overview
44

5-
Follow these four steps to upgrade Nexent safely:
5+
Follow these steps to upgrade Nexent safely:
66

7-
1. Clean up existing containers and images
8-
2. Pull the latest code and run the deployment script
9-
3. Apply database migrations
10-
4. Verify the deployment in your browser
7+
1. Pull the latest code
8+
2. Execute the upgrade script
9+
3. Open the site to confirm service availability
1110

1211
---
1312

14-
## 🧹 Step 1: Clean up old images
13+
## 🔄 Step 1: Update Code
1514

16-
Remove cached resources to avoid conflicts when redeploying:
15+
Before updating, record the current deployment version and data directory information.
16+
17+
- Current Deployment Version Location: APP_VERSION in backend/consts/const.py
18+
- Data Directory Location: ROOT_DIR in docker/.env
19+
20+
**Code downloaded via git**
21+
22+
Update the code using git commands:
23+
24+
```bash
25+
git pull
26+
```
27+
28+
**Code downloaded via ZIP package or other means**
29+
30+
1. Re-download the latest code from GitHub and extract it.
31+
2. If it exists, copy the deploy.options file from the docker directory of your previous deployment script directory to the docker directory of the new code directory. (If the file doesn't exist, you can ignore this step).
32+
33+
## 🔄 Step 2: Execute the Upgrade
34+
35+
Navigate to the docker directory of the updated code and run the upgrade script:
36+
37+
```bash
38+
bash upgrade.sh
39+
```
40+
41+
If deploy.options is missing, the script will prompt you to manually enter configuration details from the previous deployment, such as the current version and data directory. Enter the information you recorded earlier.
42+
43+
>💡 Tip
44+
> The default scenario is quick deployment, which uses .env.example.
45+
> If you need to configure voice models (STT/TTS), please add the relevant variables to .env.example in advance. We will provide a front-end configuration interface as soon as possible.
46+
47+
48+
## 🌐 Step 3: Verify the deployment
49+
50+
After deployment:
51+
52+
1. Open `http://localhost:3000` in your browser.
53+
2. Review the [User Guide](https://doc.nexent.tech/en/user-guide/home-page) to validate agent functionality.
54+
55+
56+
## Optional Operations
57+
58+
### 🧹 Clean Up Old Version Images
59+
60+
If images were not updated correctly, you can clean up old containers and images before upgrading:
1761

1862
```bash
1963
# Stop and remove existing containers
@@ -38,24 +82,9 @@ docker system prune -af
3882
3983
---
4084
41-
## 🔄 Step 2: Update code and redeploy
42-
43-
```bash
44-
git pull
45-
cd nexent/docker
46-
cp .env.example .env
47-
bash deploy.sh
48-
```
49-
50-
> 💡 Tip
51-
> - `.env.example` works for default deployments.
52-
> - Configure speech models (STT/TTS) in `.env` when needed. A frontend configuration flow is coming soon.
53-
54-
---
55-
56-
## 🗄️ Step 3: Apply database migrations
85+
## 🗄️ Manual Database Update
5786
58-
Run the SQL scripts shipped with each release to keep your schema up to date.
87+
If some SQL files fail to execute during the upgrade, you can perform the update manually.
5988
6089
### ✅ Method A: Use a SQL editor (recommended)
6190
@@ -68,8 +97,8 @@ Run the SQL scripts shipped with each release to keep your schema up to date.
6897
- Password
6998
3. Test the connection. When successful, you should see tables under the `nexent` schema.
7099
4. Open a new query window.
71-
5. Navigate to `/nexent/docker/sql`. Each file contains one migration script with its release date in the filename.
72-
6. Execute every script dated after your previous deployment, in chronological order.
100+
5. Navigate to the /nexent/docker/sql directory and open the failed SQL file(s) to view the script.
101+
6. Execute the failed SQL file(s) and any subsequent version SQL files in order.
73102
74103
> ⚠️ Important
75104
> - Always back up the database first, especially in production.
@@ -97,14 +126,12 @@ Run the SQL scripts shipped with each release to keep your schema up to date.
97126
3. Execute SQL files sequentially (host machine example):
98127
99128
```bash
100-
# Example: If today is November 6th and your last update was on October 20th,
101-
# and there are two new files 1030-update.sql and 1105-update.sql,
102129
# execute the following commands (please replace the placeholders with your actual values)
103-
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/1030-update.sql
104-
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/1105-update.sql
130+
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/v1.1.1_1030-update.sql
131+
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/v1.1.2_1105-update.sql
105132
```
106133
107-
Execute the scripts in chronological order based on your deployment date.
134+
Execute the corresponding scripts for your deployment versions in version order.
108135
109136
> 💡 Tips
110137
> - Load environment variables first if they are defined in `.env`:
@@ -126,14 +153,3 @@ Run the SQL scripts shipped with each release to keep your schema up to date.
126153
> ```bash
127154
> docker exec -i nexent-postgres pg_dump -U [YOUR_POSTGRES_USER] [YOUR_POSTGRES_DB] > backup_$(date +%F).sql
128155
> ```
129-
130-
---
131-
132-
## 🌐 Step 4: Verify the deployment
133-
134-
After deployment:
135-
136-
1. Open `http://localhost:3000` in your browser.
137-
2. Review the [User Guide](https://doc.nexent.tech/en/user-guide/home-page) to validate agent functionality.
138-
139-

doc/docs/zh/deployment/upgrade-guide.md

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,59 @@
22

33
## 🚀 升级流程概览
44

5-
升级 Nexent 时建议依次完成以下四个步骤
5+
升级 Nexent 时建议依次完成以下几个步骤
66

7-
1. 清理旧版本容器与镜像
8-
2. 拉取最新代码并执行部署脚本
9-
3. 同步数据库结构
10-
4. 打开站点确认服务可用
7+
1. 拉取最新代码
8+
2. 执行升级脚本
9+
3. 打开站点确认服务可用
1110

1211
---
1312

14-
## 🧹 步骤一:清理旧版本镜像
13+
## 🔄 步骤一:更新代码
1514

16-
为避免缓存或版本冲突,先清理旧容器与镜像:
15+
更新之前,先记录下当前部署的版本和数据目录
16+
17+
- 当前部署版本信息的位置:`backend/consts/const.py`中的 APP_VERSION
18+
- 数据目录信息的位置:`docker/.env`中的 ROOT_DIR
19+
20+
**git 方式下载的代码**
21+
22+
通过 git 指令更新代码
23+
24+
```bash
25+
git pull
26+
```
27+
28+
**zip 包等方式下载的代码**
29+
30+
需要去 github 上重新下载一份最新代码,并解压缩。另外,需要从之前执行部署脚本目录下 docker 目录中拷贝 deploy.options 到新代码目录下的 docker 目录中(如果不存在该文件则忽略)。
31+
32+
## 🔄 步骤二:执行升级
33+
34+
进入更新后代码目录的docker目录,执行升级脚本:
35+
36+
```bash
37+
bash upgrade.sh
38+
```
39+
40+
缺少 deploy.options 的情况下,会提示需要手动输入之前部署的一些配置,比如:当前部署版本、数据目录等。按照提示输入之前记录的信息即可。
41+
42+
> 💡 提示
43+
> - 默认为快速部署场景,使用 `.env.example`
44+
> - 若需配置语音模型(STT/TTS),请提前在 `.env.example` 中补充相关变量,我们将尽快提供前端配置入口。
45+
46+
## 🌐 步骤三:验证部署
47+
48+
部署完成后:
49+
50+
1. 在浏览器打开 `http://localhost:3000`
51+
2. 参考 [用户指南](https://doc.nexent.tech/zh/user-guide/home-page) 完成智能体配置与验证
52+
53+
## 可选操作
54+
55+
### 🧹 清理旧版本镜像
56+
57+
如果镜像未正确更新,可以在升级前先清理旧容器与镜像:
1758

1859
```bash
1960
# 停止并删除现有容器
@@ -39,26 +80,11 @@ docker system prune -af
3980
4081
---
4182
42-
## 🔄 步骤二:更新代码并部署
83+
### 🗄️ 手动更新数据库
4384
44-
```bash
45-
git pull
46-
cd nexent/docker
47-
cp .env.example .env
48-
bash deploy.sh
49-
```
50-
51-
> 💡 提示
52-
> - 默认为快速部署场景,可直接使用 `.env.example`
53-
> - 若需配置语音模型(STT/TTS),请在 `.env` 中补充相关变量,我们将尽快提供前端配置入口。
54-
55-
---
85+
升级时如果存在部分 sql 文件执行失败,则可以手动执行更新。
5686
57-
## 🗄️ 步骤三:同步数据库
58-
59-
升级后需要执行数据库迁移脚本,使 schema 保持最新。
60-
61-
### ✅ 方法一:使用 SQL 编辑器(推荐)
87+
#### ✅ 方法一:使用 SQL 编辑器(推荐)
6288
6389
1. 打开 SQL 编辑器,新建 PostgreSQL 连接。
6490
2. 在 `/nexent/docker/.env` 中找到以下信息:
@@ -69,15 +95,15 @@ bash deploy.sh
6995
- Password
7096
3. 填写连接信息后测试连接,确认成功后可在 `nexent` schema 中查看所有表。
7197
4. 新建查询窗口。
72-
5. 打开 `/nexent/docker/sql` 目录,按文件名中的日期顺序查看 SQL 脚本。
73-
6. 根据上次部署日期,依次执行之后的每个 SQL 文件
98+
5. 打开 `/nexent/docker/sql` 目录,通过失败的sql文件查看 SQL 脚本。
99+
6. 将失败的sql文件和后续版本的sql文件依次执行
74100
75101
> ⚠️ 注意事项
76102
> - 升版本前请备份数据库,生产环境尤为重要。
77103
> - SQL 脚本需按时间顺序执行,避免依赖冲突。
78104
> - `.env` 变量可能命名为 `POSTGRES_HOST``POSTGRES_PORT` 等,请在客户端对应填写。
79105
80-
### 🧰 方法二:命令行执行(无需客户端)
106+
#### 🧰 方法二:命令行执行(无需客户端)
81107
82108
1. 进入 Docker 目录:
83109
@@ -98,14 +124,12 @@ bash deploy.sh
98124
3. 通过容器执行 SQL 脚本(示例):
99125
100126
```bash
101-
# 假如现在是11月6日,上次更新版本的时间是10月20日
102-
# 此时新增了1030-update.sql和1105-update.sql两个文件
103127
# 我们需要执行以下命令(请注意替换占位符中的变量)
104-
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/1030-update.sql
105-
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/1105-update.sql
128+
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/v1.1.1_1030-update.sql
129+
docker exec -i nexent-postgresql psql -U [YOUR_POSTGRES_USER] -d [YOUR_POSTGRES_DB] < ./sql/v1.1.2_1105-update.sql
106130
```
107131
108-
请根据自己的部署时间,按时间顺序执行对应脚本
132+
请根据自己的部署版本,按版本顺序执行对应脚本
109133
110134
> 💡 提示
111135
> - 若 `.env` 中定义了数据库变量,可先导入:
@@ -127,12 +151,3 @@ bash deploy.sh
127151
> ```bash
128152
> docker exec -i nexent-postgres pg_dump -U [YOUR_POSTGRES_USER] [YOUR_POSTGRES_DB] > backup_$(date +%F).sql
129153
> ```
130-
131-
---
132-
133-
## 🌐 步骤四:验证部署
134-
135-
部署完成后:
136-
137-
1. 在浏览器打开 `http://localhost:3000`
138-
2. 参考 [用户指南](https://doc.nexent.tech/zh/user-guide/home-page) 完成智能体配置与验证

docker/.env.general

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
NEXENT_IMAGE=nexent/nexent:latest
2-
NEXENT_WEB_IMAGE=nexent/nexent-web:latest
3-
NEXENT_DATA_PROCESS_IMAGE=nexent/nexent-data-process:latest
1+
NEXENT_IMAGE=nexent/nexent:${APP_VERSION}
2+
NEXENT_WEB_IMAGE=nexent/nexent-web:${APP_VERSION}
3+
NEXENT_DATA_PROCESS_IMAGE=nexent/nexent-data-process:${APP_VERSION}
44

55
ELASTICSEARCH_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:8.17.4
66
POSTGRESQL_IMAGE=postgres:15-alpine
77
REDIS_IMAGE=redis:alpine
88
MINIO_IMAGE=quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
9-
OPENSSH_SERVER_IMAGE=nexent/nexent-ubuntu-terminal:latest
9+
OPENSSH_SERVER_IMAGE=nexent/nexent-ubuntu-terminal:${APP_VERSION}
1010

1111
SUPABASE_KONG=kong:2.8.1
1212
SUPABASE_GOTRUE=supabase/gotrue:v2.170.0

docker/.env.mainland

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
NEXENT_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent:latest
2-
NEXENT_WEB_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-web:latest
3-
NEXENT_DATA_PROCESS_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:latest
1+
NEXENT_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent:${APP_VERSION}
2+
NEXENT_WEB_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-web:${APP_VERSION}
3+
NEXENT_DATA_PROCESS_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:${APP_VERSION}
44

55
ELASTICSEARCH_IMAGE=elastic.m.daocloud.io/elasticsearch/elasticsearch:8.17.4
66
POSTGRESQL_IMAGE=docker.m.daocloud.io/postgres:15-alpine
77
REDIS_IMAGE=docker.m.daocloud.io/redis:alpine
88
MINIO_IMAGE=quay.m.daocloud.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
9-
OPENSSH_SERVER_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-ubuntu-terminal:latest
9+
OPENSSH_SERVER_IMAGE=ccr.ccs.tencentyun.com/nexent-hub/nexent-ubuntu-terminal:${APP_VERSION}
1010

1111
SUPABASE_KONG=docker.m.daocloud.io/kong:2.8.1
1212
SUPABASE_GOTRUE=docker.m.daocloud.io/supabase/gotrue:v2.170.0

0 commit comments

Comments
 (0)