Initial commit: 浼佷笟寰俊 AI 鏈哄櫒浜哄姪鐞?MVP
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
docs/phase7.md
Normal file
35
docs/phase7.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Phase 7:云端 CI/CD + 线上回调稳定 + 最小闭环验收
|
||||
|
||||
## CI/CD(GitHub Actions)
|
||||
|
||||
- **位置**:`.github/workflows/build-deploy.yml`(副本说明见 `deploy/ci/`)
|
||||
- **触发**:推送到 `main` 分支
|
||||
- **流程**:
|
||||
1. **test-backend**:启动 PostgreSQL 16,执行迁移,运行 `pytest tests/`
|
||||
2. **build-backend**:构建 backend 镜像并推送到 GitHub Container Registry(`ghcr.io/<owner>/wecom-ai-backend:latest`)
|
||||
3. **build-admin**:构建 admin 镜像并推送(`ghcr.io/<owner>/wecom-ai-admin:latest`)
|
||||
|
||||
## 云端部署(方案 A)
|
||||
|
||||
1. 服务器安装 Docker + docker-compose。
|
||||
2. 从 GHCR 拉取镜像(或从仓库 build):
|
||||
- 使用 `docker-compose.yml` 时,可改为使用 `image: ghcr.io/<owner>/wecom-ai-backend:latest` 等,不再本地 build。
|
||||
3. 配置 `.env`(含 `WECOM_*`、`DATABASE_URL`、`JWT_SECRET` 等)。
|
||||
4. 执行:`docker-compose up -d`。
|
||||
5. 配置 Nginx 反代或直接暴露端口;HTTPS 证书后补。
|
||||
|
||||
## 无 GitHub 时(GitLab CI 替代)
|
||||
|
||||
在仓库根目录创建 `.gitlab-ci.yml`,阶段与上述对应:
|
||||
`test`(postgres service + migrate + pytest)、`build`(docker build + push 到 GitLab Registry)。变量使用 `CI_REGISTRY`、`CI_REGISTRY_USER`、`CI_REGISTRY_PASSWORD`。
|
||||
|
||||
## 最小闭环验收脚本
|
||||
|
||||
- **路径**:`deploy/scripts/acceptance.sh`
|
||||
- **用法**:`BASE_URL=http://localhost ./acceptance.sh` 或 `BASE_URL=https://你的域名 ./acceptance.sh`
|
||||
- **步骤**:
|
||||
1. `GET /api/health` 期望 200
|
||||
2. `POST /api/auth/login`(admin/admin)期望 `code: 0`
|
||||
3. `GET /api/wecom/callback?...` 期望 200 或 400(验签失败为 400)
|
||||
|
||||
全部通过即打印 "All checks passed"。
|
||||
Reference in New Issue
Block a user