docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.1k stars 525 forks source link

using `outputs: type=local,dest=$GITHUB_WORKSPACE` with multiarch has unexpected behavior #1126

Closed jdrouet closed 1 month ago

jdrouet commented 1 month ago

Contributing guidelines

I've found a bug, and:

Description

I want to use an actual Dockerfile to build a binary, using the platforms parameter and outputs: type=local.... In my dockerfile, I use the multiarch feature to build the binary and copy it in a target FROM scratch. When I run it locally using docker buildx build --platform linux/arm64,linux/amd64 --target binary --output type=local,dest=$(pwd), it creates 2 directories, linux_amd64 and linux_arm64 in which I find the binaries. With this gh action, I only get a single binary.

Expected behaviour

With this configuration

 - name: build binaries using buildx
   uses: docker/build-push-action@v5
   with:
     cache-from: type=gha
     cache-to: type=gha,mode=max
     outputs: type=local,dest=$GITHUB_WORKSPACE
     platform: linux/amd64,linux/arm64
     push: false
     target: binary

I'd expect to find $GITHUB_WORKSPACE/linux_amd64/my-binary and $GITHUB_WORKSPACE/linux_arm64/my-binary but I only get $GITHUB_WORKSPACE/my-binary.

Actual behaviour

With this configuration

 - name: build binaries using buildx
   uses: docker/build-push-action@v5
   with:
     cache-from: type=gha
     cache-to: type=gha,mode=max
     outputs: type=local,dest=$GITHUB_WORKSPACE
     platform: linux/amd64,linux/arm64
     push: false
     target: binary

I only get $GITHUB_WORKSPACE/my-binary.

Repository URL

https://github.com/jdrouet/git-metrics

Workflow run URL

https://github.com/jdrouet/git-metrics/actions/runs/9250622026/job/25444518546

YAML workflow

name: release

on:
  pull_request:

jobs:
  build-binaries:
    name: build binaries
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v3
      - name: set up qemu
        uses: docker/setup-qemu-action@v3
      - name: set up docker buildx
        uses: docker/setup-buildx-action@v3
      - name: build binaries using buildx
        uses: docker/build-push-action@v5
        with:
          cache-from: type=gha
          cache-to: type=gha,mode=max
          outputs: type=local,dest=$GITHUB_WORKSPACE
          platform: linux/amd64,linux/arm64
          push: false
          target: binary
      - name: show files
        run: ls -lha $GITHUB_WORKSPACE/*

Workflow logs

See https://github.com/jdrouet/git-metrics/actions/runs/9250622026/job/25444518546

BuildKit logs

No response

Additional info

No response

crazy-max commented 1 month ago

platform is not a valid input as stated in logs: https://github.com/jdrouet/git-metrics/actions/runs/9250622026/job/25444518546#step:5:1

image

Should be platforms.

jdrouet commented 1 month ago

Ah, fair enough. Thank you for that.