Build Printer Docker Image (ARM64) #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Printer Docker Image (ARM64) | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/build-docker.yml' | |
| pull_request: | |
| branches: [ "main" ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/build-docker.yml' | |
| workflow_dispatch: # 保留手动触发,无需架构选择(仅arm64) | |
| jobs: | |
| build-arm64: | |
| name: Build ARM64 Image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build ARM64 Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/arm64 # 仅构建arm64架构 | |
| push: false # 不推送 | |
| tags: printer-cups:arm64-local # 明确的arm64标签 | |
| cache-from: type=gha,scope=arm64 # 单独的arm64缓存 | |
| cache-to: type=gha,scope=arm64,mode=max | |
| # 关键:将构建的镜像导出为 tar 文件 | |
| outputs: type=docker,dest=/tmp/printer-cups-arm64.tar | |
| - name: Compress image (减小体积) | |
| run: gzip /tmp/printer-cups-arm64.tar | |
| - name: Upload image as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: printer-cups-arm64-image | |
| path: /tmp/printer-cups-arm64.tar.gz | |
| retention-days: 3 # 镜像保留 天,可按需修改 |