Build bake change

This commit is contained in:
YuCat 2024-05-07 21:15:53 +08:00
parent cbee6ee7f3
commit 4c954be688
2 changed files with 25 additions and 29 deletions

View File

@ -52,12 +52,6 @@ jobs:
run: |
mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Upload meta bake definition
uses: actions/upload-artifact@v4
with:
@ -114,11 +108,13 @@ jobs:
- name: Build
id: bake
uses: docker/bake-action@v4
env:
PLATFORM: ${{ env.ARCH }}
with:
files: |
./docker-bake.hcl
/tmp/bake-meta.json
targets: ${{ env.PLATFORM_PAIR }}
targets: image
set: |
*.tags=
*.platform=${{ matrix.platform }}
@ -126,18 +122,10 @@ jobs:
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_PAIR }}
*.output=type=image,"name=${{ env.DOCKERHUB_SLUG }},${{ env.GHCR_SLUG }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest (amd64)
if: matrix.platform == 'linux/amd64'
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ fromJSON(steps.bake.outputs.metadata).image-amd64['containerimage.digest'] }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Export digest (arm64)
if: matrix.platform == 'linux/arm64'
run: |
mkdir -p /tmp/digests
digest="${{ fromJSON(steps.bake.outputs.metadata).image-arm64['containerimage.digest'] }}"
digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest

View File

@ -2,24 +2,32 @@ variable "DEFAULT_TAG" {
default = "baidunetdisk-docker:latest"
}
group "linux-amd64" {
targets = ["image-amd64"]
}
group "linux-arm64" {
targets = ["image-arm64"]
variable "ARCH" {
default = "arm64"
}
target "docker-metadata-action" {
tags = ["${DEFAULT_TAG}"]
}
// Default target if none specified
group "default" {
targets = ["image-local"]
}
target "image-amd64" {
platforms = ["linux/amd64"]
target "image" {
inherits = ["docker-metadata-action"]
dockerfile = "Dockerfile"
dockerfile = format("Dockerfile%s", equal("arm64", ARCH) ? "" : ".${ARCH}")
}
target "image-arm64" {
platforms = ["linux/arm64"]
inherits = ["docker-metadata-action"]
dockerfile = "Dockerfile.arm64"
target "image-local" {
inherits = ["image"]
output = ["type=docker"]
}
target "image-all" {
inherits = ["image"]
platforms = [
"linux/amd64",
"linux/arm64",
]
}