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.11k stars 527 forks source link

`build` is interpreted as file instead of argument #1012

Closed norman-zon closed 7 months ago

norman-zon commented 7 months ago

Contributing guidelines

I've found a bug, and:

Description

The build part of the /usr/bin/docker buildx build ... command is interpreted as a file path, instead of a command argument.

Expected behaviour

build is interpreted as argument to the docker buildx command

Actual behaviour

/usr/bin/docker buildx build --file ./build/Dockerfile [...] .
ERROR: could not find build: stat build: no such file or directory

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Build Migrator Image

on:
  workflow_dispatch:
    inputs:
      MigratorTag:
        description: 'The tag of the image to build'
        required: true
        type: string
env:
  ENVIRONMENT: devel
  PROJECT: xxx
  IMAGE: xxx

jobs:
  build-and-deploy:
    name: Build and deploy
    runs-on: zon-ubuntu-general-dind

    permissions:
      id-token: write
      contents: read

    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: Baseproject
        id: baseproject
        uses: ZeitOnline/gh-action-baseproject@v0
        with:
          project_name: ${{ env.PROJECT }}
          environment: ${{ env.ENVIRONMENT }}
          gar_docker_auth: true

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        id: buildx
        with:
          driver: docker

      - name: Build and push Docker Image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: ./build/Dockerfile
          push: true
          target: migrator
          tags: |
            ${{ env.IMAGE }}:${{ inputs.MigratorTag }}
            ${{ env.IMAGE }}:latest
      - name: Show Image Tag
        run: |
          echo "### Image Tag: ${{ inputs.MigratorTag }}:rocket:" >> $GITHUB_STEP_SUMMARY

Workflow logs

No response

BuildKit logs

No response

Additional info

Running on self-hosted runners, using ghcr.io/actions/actions-runner v2.311.0

crazy-max commented 7 months ago

could not find build

It means ./build folder doesn't exist. You can add an additional step before "Build and push Docker Image" to make sure of it:

      - run: ls -al

      - name: Build and push Docker Image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: ./build/Dockerfile
          push: true
          target: migrator
          tags: |
            ${{ env.IMAGE }}:${{ inputs.MigratorTag }}
            ${{ env.IMAGE }}:latest
norman-zon commented 7 months ago

🙈 I'm very sorry. Should have caught that myself.