chore: build and deploy web-antd
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 8s
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 8s
This commit is contained in:
@@ -108,6 +108,32 @@ jobs:
|
||||
--restart always \
|
||||
-p ${HOST_PORT}:80 \
|
||||
"${IMAGE_NAME}:latest"
|
||||
|
||||
|
||||
# 等待容器启动
|
||||
echo "Waiting for container to start..."
|
||||
sleep 3
|
||||
|
||||
# 检查容器状态
|
||||
CONTAINER_STATUS=$(docker ps -a --filter "name=$CONTAINER_NAME" --format "{{.Status}}" | head -1)
|
||||
if [ -z "$CONTAINER_STATUS" ]; then
|
||||
echo "❌ Error: Container failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查容器是否正在运行
|
||||
if docker ps --filter "name=$CONTAINER_NAME" --format "{{.Names}}" | grep -q "$CONTAINER_NAME"; then
|
||||
echo "✅ Container is running"
|
||||
else
|
||||
echo "❌ Error: Container is not running"
|
||||
echo "Container status: $CONTAINER_STATUS"
|
||||
echo "Container logs:"
|
||||
docker logs $CONTAINER_NAME --tail 50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 显示容器信息
|
||||
echo "Container info:"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
|
||||
echo "✅ Deployment Successful! Access at port ${HOST_PORT}"
|
||||
|
||||
|
||||
@@ -273,7 +273,12 @@ pnpm dev:antd
|
||||
|
||||
4. **Git 提交信息包含 `[skip ci]`**:
|
||||
- 如果提交信息包含 `[skip ci]`,CI/CD 会被跳过
|
||||
- 解决:使用其他提交信息
|
||||
- **重要**:构建脚本已更新,不再使用 `[skip ci]` 标记
|
||||
- 如果之前使用了 `[skip ci]`,需要重新提交:
|
||||
```bash
|
||||
git commit --amend -m "chore: build and deploy web-antd"
|
||||
git push origin master --force
|
||||
```
|
||||
|
||||
5. **Gitea Actions 未启用**:
|
||||
- 检查 Gitea 仓库设置中 Actions 是否启用
|
||||
@@ -291,3 +296,90 @@ pnpm dev:antd
|
||||
git push origin master
|
||||
```
|
||||
4. 或者使用自动化脚本:`./scripts/deploy/build-and-push.sh`
|
||||
|
||||
### 问题:构建成功但服务没有运行
|
||||
|
||||
**可能原因和解决方案**:
|
||||
|
||||
1. **容器启动失败**:
|
||||
```bash
|
||||
# 在服务器上检查容器状态
|
||||
docker ps -a | grep aiot-web-antd
|
||||
|
||||
# 查看容器日志
|
||||
docker logs aiot-web-antd
|
||||
|
||||
# 如果容器不存在,检查 CI/CD 日志
|
||||
```
|
||||
|
||||
2. **端口被占用**:
|
||||
```bash
|
||||
# 检查端口 9090 是否被占用
|
||||
netstat -tuln | grep 9090
|
||||
# 或
|
||||
lsof -i :9090
|
||||
|
||||
# 检查是否有其他容器占用端口
|
||||
docker ps --filter "publish=9090"
|
||||
```
|
||||
|
||||
3. **Nginx 配置错误**:
|
||||
```bash
|
||||
# 进入容器检查 nginx 配置
|
||||
docker exec -it aiot-web-antd sh
|
||||
nginx -t # 测试配置
|
||||
cat /etc/nginx/conf.d/default.conf # 查看配置
|
||||
```
|
||||
|
||||
4. **构建产物问题**:
|
||||
```bash
|
||||
# 检查容器内的文件
|
||||
docker exec -it aiot-web-antd ls -la /usr/share/nginx/html
|
||||
|
||||
# 检查 index.html 是否存在
|
||||
docker exec -it aiot-web-antd cat /usr/share/nginx/html/index.html
|
||||
```
|
||||
|
||||
5. **网络问题**:
|
||||
```bash
|
||||
# 检查容器网络
|
||||
docker network inspect 1panel-network
|
||||
|
||||
# 检查容器是否在正确的网络中
|
||||
docker inspect aiot-web-antd | grep NetworkMode
|
||||
```
|
||||
|
||||
6. **手动启动容器测试**:
|
||||
```bash
|
||||
# 停止现有容器
|
||||
docker stop aiot-web-antd || true
|
||||
docker rm aiot-web-antd || true
|
||||
|
||||
# 手动启动容器(前台运行,查看输出)
|
||||
docker run --rm \
|
||||
--name aiot-web-antd-test \
|
||||
--network 1panel-network \
|
||||
-p 9090:80 \
|
||||
aiot-web-antd:latest
|
||||
```
|
||||
|
||||
7. **检查 CI/CD 日志**:
|
||||
- 查看 Gitea Actions 的完整日志
|
||||
- 检查是否有错误信息
|
||||
- 确认容器是否成功启动
|
||||
|
||||
**快速诊断命令**(在服务器上执行):
|
||||
```bash
|
||||
# 一键诊断脚本
|
||||
echo "=== Container Status ==="
|
||||
docker ps -a | grep aiot-web-antd
|
||||
|
||||
echo "=== Container Logs (last 50 lines) ==="
|
||||
docker logs aiot-web-antd --tail 50
|
||||
|
||||
echo "=== Port Status ==="
|
||||
netstat -tuln | grep 9090
|
||||
|
||||
echo "=== Container Files ==="
|
||||
docker exec aiot-web-antd ls -la /usr/share/nginx/html | head -10
|
||||
```
|
||||
|
||||
@@ -57,7 +57,8 @@ if ($response -eq "y" -or $response -eq "Y") {
|
||||
|
||||
Write-Host "Committing changes..." -ForegroundColor Yellow
|
||||
# 使用 --no-verify 跳过 pre-commit hooks,避免检查大量构建产物文件
|
||||
git commit --no-verify -m "chore: build and deploy web-antd [skip ci]" 2>&1 | Out-Null
|
||||
# 注意:不要使用 [skip ci],否则 CI/CD 不会触发
|
||||
git commit --no-verify -m "chore: build and deploy web-antd" 2>&1 | Out-Null
|
||||
|
||||
Write-Host "Pushing to repository..." -ForegroundColor Yellow
|
||||
git push origin master
|
||||
|
||||
@@ -54,7 +54,8 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
|
||||
echo "💾 Committing changes..."
|
||||
# 使用 --no-verify 跳过 pre-commit hooks,避免检查大量构建产物文件
|
||||
git commit --no-verify -m "chore: build and deploy web-antd [skip ci]" || true
|
||||
# 注意:不要使用 [skip ci],否则 CI/CD 不会触发
|
||||
git commit --no-verify -m "chore: build and deploy web-antd" || true
|
||||
|
||||
echo "📤 Pushing to repository..."
|
||||
git push origin master
|
||||
|
||||
Reference in New Issue
Block a user