chore: 改为本地构建,传dist文件到服务端
Some checks failed
Web UI CI/CD / build-and-deploy (push) Has been cancelled

This commit is contained in:
lzh
2025-12-23 13:43:32 +08:00
parent f605d50f51
commit 25ebd947b8
5 changed files with 332 additions and 18 deletions

View File

@@ -5,12 +5,11 @@ on:
branches:
- master
paths:
# 仅当以下文件变动时触发构建,避免改个 README 也重新发版
- 'apps/web-antd/**'
- 'packages/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'Dockerfile'
# 仅当构建产物 dist 目录变化时触发部署
# 修改源码不会触发,需要先在本地构建后推送 dist 目录
- 'apps/web-antd/dist/**'
- 'apps/web-antd/nginx.conf'
- 'Dockerfile.deploy'
- '.gitea/workflows/deploy-web.yaml'
jobs:
@@ -49,7 +48,20 @@ jobs:
# 检查 1panel-network 是否存在,如果不存在则创建
docker network inspect 1panel-network > /dev/null 2>&1 || docker network create 1panel-network || true
# 3. 构建并部署
# 3. 检查构建产物(必须存在)
- name: Check Build Artifacts
run: |
if [ ! -d "apps/web-antd/dist" ] || [ -z "$(ls -A apps/web-antd/dist 2>/dev/null)" ]; then
echo "❌ Error: Build artifacts not found in apps/web-antd/dist"
echo "Please build locally first: pnpm build:antd"
echo "Then run: ./scripts/deploy/build-and-push.sh"
exit 1
fi
echo "✅ Build artifacts found"
BUILD_SIZE=$(du -sh apps/web-antd/dist | cut -f1)
echo "📊 Build size: $BUILD_SIZE"
# 4. 构建并部署(只打包,不构建)
- name: Build & Deploy Web UI
env:
# 镜像名称
@@ -59,17 +71,14 @@ jobs:
# 宿主机端口
HOST_PORT: 9090
run: |
# --- 构建阶段 ---
SHORT_SHA=$(git log -1 --format='%h')
FULL_IMAGE_NAME="${IMAGE_NAME}:${SHORT_SHA}"
echo "Building Docker Image: $FULL_IMAGE_NAME..."
echo "🚀 Building Docker Image (deploy only, no build): $FULL_IMAGE_NAME..."
# 使用根目录的 Dockerfile 进行构建
# Dockerfile 内部使用了多阶段构建,不需要 Runner 安装 Node
# 启用 BuildKit 以支持缓存挂载(加速依赖安装)
# 注意资源限制已在Dockerfile内部通过并发限制和内存限制实现
DOCKER_BUILDKIT=1 docker build -t "$FULL_IMAGE_NAME" -f Dockerfile .
# 使用 Dockerfile.deploy只复制构建产物进行构建
# 这样可以避免服务器资源占用
DOCKER_BUILDKIT=1 docker build -t "$FULL_IMAGE_NAME" -f Dockerfile.deploy .
# 打上 latest 标签
docker tag "$FULL_IMAGE_NAME" "${IMAGE_NAME}:latest"