Skip to content

Uncertain behavior of local source #352

Description

@ModerNews

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

The documentation claims:

| source | String | Context to build from. Can be either local (.) or a remote bake definition |

Expected behaviour

According to this, the source can be either a (git) remote bake definition, or a directory (at least I'd assume . to mean CWD).

Actual behaviour

However with definition like this (repo name censored out):

  with:
    source: /home/runner/work/###############/###############
    push: true
    files: ./docker-bake.hcl
  /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-tags.json
  /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-labels.json
  /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-tags.json
  /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-labels.json
  /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-tags.json
  /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-labels.json

It produces command looking like this

  /usr/bin/docker buildx bake --file ./docker-bake.hcl --file /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-tags.json --file /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-labels.json --file /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-tags.json --file /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-labels.json --file /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-tags.json --file /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-labels.json --file /home/runner/work/###############/############### --push --print

Notice the source was added at the end --file /home/runner/work/###############/###############.

This is a huge discrepancy in the documentation, and while not a big hassle to fix between runs, it should be either replaced in documentation, to reflect that it cannot be a directory, or behave like context in docker/build-push-action, which is how the documentation states it right now.

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Build and Push Docker Images

on:
  push:
    branches:
      - main

jobs:
  build-for-ghcr:
    runs-on: ubuntu-latest
    permissions:
      packages: write
      contents: read
      statuses: read
    steps:
      - uses: actions/checkout@v4
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Login to GHCR
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}
      - name: Prepare Docker metadata
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}-api-gateway
          bake-target: api-gateway
          tags: |
            type=sha
      - name: Build and push Docker images
        uses: docker/bake-action@v6
        with:
          source: ${{ github.workspace }}
          push: true
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file-tags }}
            ${{ steps.meta.outputs.bake-file-labels }}

Workflow logs

No response

BuildKit logs

  #1 [internal] load local bake definitions
  #1 reading ./docker-bake.hcl 798B / 798B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-tags.json 393B / 393B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-mzMN4H/docker-metadata-action-bake-labels.json 624B / 624B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-tags.json 408B / 408B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-t6S7zL/docker-metadata-action-bake-labels.json 627B / 627B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-tags.json 376B / 376B done
  #1 reading /home/runner/work/_temp/docker-actions-toolkit-jFIRMF/docker-metadata-action-bake-labels.json 623B / 623B done
  #1 reading /home/runner/work/###############/############### 0B / 4.10kB done
  #1 DONE 0.0s
  ERROR: read /home/runner/work/###############/###############: is a directory
Error: cannot parse bake definitions: ERROR: read /home/runner/work/###############/###############: is a directory

Additional info

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions