refactor: 更新Docker工作流,切换到Alpine基础镜像并添加依赖安装步骤
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 10s

This commit is contained in:
lan
2025-12-02 11:47:51 +08:00
parent 71c8e1b9d2
commit d45ca9afe2

View File

@@ -18,15 +18,24 @@ jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: gcr.io/kaniko-project/executor:debug image: alpine:3.19
options: --entrypoint ""
steps: steps:
- name: Install dependencies
run: |
apk add --no-cache curl git bash
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Download Kaniko
run: |
mkdir -p /kaniko
curl -L https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64 -o /kaniko/executor
chmod +x /kaniko/executor
- name: Create registry config - name: Create registry config
run: | run: |
mkdir -p /kaniko/.docker mkdir -p /kaniko/.docker
@@ -40,11 +49,10 @@ jobs:
} }
} }
EOF EOF
echo "Registry config created" echo "Registry config created for ${{ env.REGISTRY }}"
- name: Build and push image - name: Build and push image
run: | run: |
# 获取短 SHA
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
REF_NAME="${{ github.ref_name }}" REF_NAME="${{ github.ref_name }}"
REF="${{ github.ref }}" REF="${{ github.ref }}"
@@ -65,14 +73,11 @@ jobs:
--context "${GITHUB_WORKSPACE}" \ --context "${GITHUB_WORKSPACE}" \
--dockerfile "${GITHUB_WORKSPACE}/Dockerfile" \ --dockerfile "${GITHUB_WORKSPACE}/Dockerfile" \
$DESTINATIONS \ $DESTINATIONS \
--cache=true \ --cache=false \
--cache-repo=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/cache \ --snapshot-mode=redo
--snapshot-mode=redo \
--use-new-run
- name: Build complete - name: Build complete
run: | run: |
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 }}"