chore(deploy): 完成 #35 部署准备

This commit is contained in:
root
2026-03-04 18:42:40 +08:00
parent 3301acf6e6
commit cc775dff45
5 changed files with 168 additions and 1 deletions
+56
View File
@@ -0,0 +1,56 @@
# 保质期小程序部署说明
## 1. 准备
1. 复制环境变量模板:
```bash
cp .env.example .env
```
2. 按实际环境填写 `.env`:数据库、Redis、AI、七牛、小程序 AppID、API 域名。
3. 确认域名解析到部署机:
- `api.example.com -> 服务器公网 IP`
## 2. 数据库初始化
```bash
mysql -h <host> -u <user> -p <db_name> < docs/sql/expiry.sql
```
## 3. 一键部署(Docker Compose
```bash
docker compose -f docker-compose.prod.yml up -d --build
```
## 4. Nginx HTTPS 配置
1. 修改 `deploy/nginx/wx_service_https.conf``server_name` 与证书路径。
2. 挂载证书目录(例如 `/etc/letsencrypt`)。
3. 重载 Nginx
```bash
docker exec wx_service_nginx nginx -s reload
```
## 5. 验证
1. 健康检查:
```bash
curl -i https://api.example.com/healthz
curl -i https://api.example.com/api/expiry/healthz
```
2. 接口联调:
```bash
BASE_URL=https://api.example.com TOKEN=<session_key> scripts/expiry/run_integration_tests.sh
```
## 6. 小程序侧配置
1. `manifest.json` 配置正式 `appid`
2. 在小程序后台添加服务器域名:
- request 合法域名:`https://api.example.com`
3. 发布前执行:
```bash
# 在前端仓库 expiry_uniapp 中
npm install
npm run build -- wx
```
## 7. 回滚
```bash
docker compose -f docker-compose.prod.yml down
# 回滚到上一版本镜像后再 up -d
```