Some checks are pending
Build and Deploy / test-backend (push) Waiting to run
Build and Deploy / build-backend (push) Blocked by required conditions
Build and Deploy / build-admin (push) Waiting to run
Deploy to Production / build-backend (push) Waiting to run
Deploy to Production / deploy (push) Blocked by required conditions
Co-authored-by: Cursor <cursoragent@cursor.com>
165 lines
4.1 KiB
Markdown
165 lines
4.1 KiB
Markdown
# 验证构建和推送是否成功
|
||
|
||
## 快速验证步骤
|
||
|
||
### 1. 检查本地镜像
|
||
|
||
```powershell
|
||
# 查看所有 registry.667788.cool 的镜像
|
||
docker images registry.667788.cool/wecom-backend
|
||
docker images registry.667788.cool/wecom-admin
|
||
docker images registry.667788.cool/wecom-nginx
|
||
|
||
# 或查看所有镜像
|
||
docker images | Select-String "registry.667788.cool"
|
||
```
|
||
|
||
**预期结果**:应该看到三个镜像:
|
||
- `registry.667788.cool/wecom-backend:latest`
|
||
- `registry.667788.cool/wecom-admin:latest`
|
||
- `registry.667788.cool/wecom-nginx:latest`
|
||
|
||
### 2. 检查镜像详细信息
|
||
|
||
```powershell
|
||
# 查看镜像详细信息
|
||
docker images registry.667788.cool/wecom-backend:latest --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
|
||
docker images registry.667788.cool/wecom-admin:latest --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
|
||
docker images registry.667788.cool/wecom-nginx:latest --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
|
||
```
|
||
|
||
### 3. 测试镜像是否可以运行
|
||
|
||
```powershell
|
||
# 测试 Backend 镜像(检查 Python 版本)
|
||
docker run --rm registry.667788.cool/wecom-backend:latest python --version
|
||
|
||
# 测试 Admin 镜像(检查 Node 版本)
|
||
docker run --rm registry.667788.cool/wecom-admin:latest node --version
|
||
|
||
# 测试 Nginx 镜像(检查 Nginx 版本)
|
||
docker run --rm registry.667788.cool/wecom-nginx:latest nginx -v
|
||
```
|
||
|
||
**预期结果**:每个命令都应该成功执行并显示版本信息。
|
||
|
||
### 4. 验证镜像是否已推送到 Registry
|
||
|
||
```powershell
|
||
# 登录 Registry(如果需要)
|
||
docker login registry.667788.cool
|
||
|
||
# 尝试拉取镜像(如果已推送,应该能拉取)
|
||
docker pull registry.667788.cool/wecom-backend:latest
|
||
docker pull registry.667788.cool/wecom-admin:latest
|
||
docker pull registry.667788.cool/wecom-nginx:latest
|
||
```
|
||
|
||
**预期结果**:
|
||
- 如果镜像已推送:会显示 "Image is up to date" 或重新下载
|
||
- 如果镜像未推送:会显示 "not found" 或 "unauthorized"
|
||
|
||
### 5. 检查构建日志
|
||
|
||
如果构建失败,查看构建日志:
|
||
|
||
```powershell
|
||
# 查看最近的构建输出
|
||
# 或重新运行构建脚本查看详细输出
|
||
.\scripts\build_and_push.ps1
|
||
```
|
||
|
||
## 完整验证清单
|
||
|
||
- [ ] 本地镜像已构建
|
||
- [ ] `registry.667788.cool/wecom-backend:latest` 存在
|
||
- [ ] `registry.667788.cool/wecom-admin:latest` 存在
|
||
- [ ] `registry.667788.cool/wecom-nginx:latest` 存在
|
||
|
||
- [ ] 镜像可以正常运行
|
||
- [ ] Backend 镜像可以运行 Python
|
||
- [ ] Admin 镜像可以运行 Node
|
||
- [ ] Nginx 镜像可以运行 Nginx
|
||
|
||
- [ ] 镜像已推送到 Registry
|
||
- [ ] 可以成功拉取 Backend 镜像
|
||
- [ ] 可以成功拉取 Admin 镜像
|
||
- [ ] 可以成功拉取 Nginx 镜像
|
||
|
||
## 常见问题
|
||
|
||
### 问题:镜像未找到
|
||
|
||
**原因**:构建可能失败或未完成
|
||
|
||
**解决方案**:
|
||
```powershell
|
||
# 重新运行构建脚本
|
||
.\scripts\build_and_push.ps1
|
||
|
||
# 查看详细输出,检查错误信息
|
||
```
|
||
|
||
### 问题:推送失败
|
||
|
||
**原因**:Registry 需要认证或网络问题
|
||
|
||
**解决方案**:
|
||
```powershell
|
||
# 登录 Registry
|
||
docker login registry.667788.cool
|
||
|
||
# 重新推送
|
||
docker push registry.667788.cool/wecom-backend:latest
|
||
docker push registry.667788.cool/wecom-admin:latest
|
||
docker push registry.667788.cool/wecom-nginx:latest
|
||
```
|
||
|
||
### 问题:镜像可以构建但无法推送
|
||
|
||
**检查项**:
|
||
1. Registry 是否需要认证
|
||
2. 网络连接是否正常
|
||
3. 镜像名称格式是否正确
|
||
|
||
## 一键验证脚本
|
||
|
||
运行验证脚本:
|
||
|
||
```powershell
|
||
.\scripts\verify-build.ps1
|
||
```
|
||
|
||
脚本会自动检查:
|
||
- 本地镜像是否存在
|
||
- Registry 连接是否正常
|
||
- 镜像是否可以拉取
|
||
|
||
## 成功标志
|
||
|
||
如果看到以下输出,说明构建和推送成功:
|
||
|
||
```
|
||
✓ Backend 镜像已构建
|
||
✓ Admin 镜像已构建
|
||
✓ Nginx 镜像已构建
|
||
✓ 所有镜像已推送到 Registry
|
||
```
|
||
|
||
## 下一步
|
||
|
||
验证成功后:
|
||
|
||
1. **在服务器上部署**:
|
||
```bash
|
||
cd deploy
|
||
docker login registry.667788.cool
|
||
docker compose -f docker-compose.prod.yml --env-file .env.prod pull
|
||
docker compose -f docker-compose.prod.yml --env-file .env.prod up -d
|
||
```
|
||
|
||
2. **验证部署**:
|
||
```bash
|
||
curl http://your-server/api/health
|
||
```
|