ci(docker): Optimize Docker build workflow and configuration

- Add environment variable for Docker registry image to reduce duplication
- Set job timeout to 60 minutes to prevent hanging builds
- Update docker/build-push-action from v5 to v6 for latest features
- Configure Docker Buildx with moby/buildkit:latest and host network
- Disable provenance attestation to improve build performance
- Replace hardcoded registry image reference with env variable for maintainability
This commit is contained in:
Lan
2025-12-18 23:19:37 +08:00
parent 900541baa5
commit b2bfc045c2
+11 -2
View File
@@ -8,9 +8,13 @@ on:
tags: tags:
- 'v*' - 'v*'
env:
REGISTRY_IMAGE: ${{ secrets.DOCKER_USERNAME }}/filecodebox
jobs: jobs:
buildx: buildx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 60
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -21,7 +25,7 @@ jobs:
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ secrets.DOCKER_USERNAME }}/filecodebox images: ${{ env.REGISTRY_IMAGE }}
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=ref,event=pr type=ref,event=pr
@@ -35,6 +39,10 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v3 uses: docker/login-action@v3
@@ -43,7 +51,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
@@ -52,3 +60,4 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
provenance: false