refactor: 更新Docker工作流,切换到Node基础镜像并优化依赖安装和构建输出
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 1m15s

This commit is contained in:
lan
2025-12-02 11:49:39 +08:00
parent d45ca9afe2
commit 653acebe47

View File

@@ -18,12 +18,13 @@ jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: alpine:3.19 image: node:20-bookworm # Debian 镜像,包含完整工具链
steps: steps:
- name: Install dependencies - name: Install dependencies
run: | run: |
apk add --no-cache curl git bash apt-get update
apt-get install -y curl git ca-certificates
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -35,6 +36,7 @@ jobs:
mkdir -p /kaniko mkdir -p /kaniko
curl -L https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64 -o /kaniko/executor curl -L https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64 -o /kaniko/executor
chmod +x /kaniko/executor chmod +x /kaniko/executor
echo "Kaniko 下载完成"
- name: Create registry config - name: Create registry config
run: | run: |
@@ -49,7 +51,7 @@ jobs:
} }
} }
EOF EOF
echo "Registry config created for ${{ env.REGISTRY }}" echo "Registry 认证配置完成: ${{ env.REGISTRY }}"
- name: Build and push image - name: Build and push image
run: | run: |
@@ -66,7 +68,10 @@ jobs:
DESTINATIONS="$DESTINATIONS --destination=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" DESTINATIONS="$DESTINATIONS --destination=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
fi fi
echo "构建目标: $DESTINATIONS" echo "=============================="
echo "开始构建 Docker 镜像"
echo "目标: $DESTINATIONS"
echo "=============================="
# 使用 Kaniko 构建并推送 # 使用 Kaniko 构建并推送
/kaniko/executor \ /kaniko/executor \
@@ -76,8 +81,11 @@ jobs:
--cache=false \ --cache=false \
--snapshot-mode=redo --snapshot-mode=redo
- name: Build complete - name: Build summary
run: | run: |
echo "=============================="
echo "✅ 镜像构建完成!" echo "✅ 镜像构建完成!"
echo "仓库: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" echo "仓库: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "分支: ${{ github.ref_name }}" echo "分支: ${{ github.ref_name }}"
echo "提交: ${{ github.sha }}"
echo "=============================="