Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 broke interaction with docker/metadata-action #287

Closed
3 tasks done
davhdavh opened this issue Jan 20, 2025 · 2 comments
Closed
3 tasks done

V6 broke interaction with docker/metadata-action #287

davhdavh opened this issue Jan 20, 2025 · 2 comments

Comments

@davhdavh
Copy link

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

existing build scripts using docker/metadata-action are failing with v6 due to confusion about where the files are located

Expected behaviour

build success

Actual behaviour

ERROR: failed to solve: lstat /actions-runner/_work/_temp/docker-actions-toolkit-YZDiwT/docker-metadata-action-bake.json: no such file or directory

Repository URL

No response

Workflow run URL

No response

YAML workflow

- name: Docker meta
      id: meta-yyy
      uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
      with:
        images: |
          ${{ secrets.DOCKER_USERNAME }}/xxx
        flavor: |
          latest=false
          prefix=yyy-
        tags: |
          type=raw,value=${{ github.run_number }}
        labels: |
          org.opencontainers.image.title=xxx
          org.opencontainers.image.description=xxx
          org.opencontainers.image.vendor=xxx
        bake-target: yyy-tags

    - name: Build
      uses: docker/bake-action@60f5d53310314dbf8c33f0c8a01042536f2f6c36 # v6
      with:
        files: |
          ./docker-bake.json
          ${{ steps.meta-yyy.outputs.bake-file }}
        targets: default
        push: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate') }}
        pull: true #always pull latest version of base images of whatever we are building

Workflow logs

No response

BuildKit logs


Additional info

No response

@crazy-max
Copy link
Member

crazy-max commented Jan 20, 2025

As v6 is now using Git context by default (https://github.com/docker/bake-action/releases/tag/v6.0.0), it needs some changes in the metadata-action step: https://github.com/docker/metadata-action?tab=readme-ov-file#bake-definition

You need to use the local bake file by specifying the cwd:// prefix when building with a git context, otherwise it will try to look at this file within the git repo.

In your case:

    - name: Build
      uses: docker/bake-action@60f5d53310314dbf8c33f0c8a01042536f2f6c36 # v6
      with:
        files: |
          ./docker-bake.json
          cwd://${{ steps.meta-yyy.outputs.bake-file }}
        targets: default
        push: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate') }}
        pull: true #always pull latest version of base images of whatever we are building

More info: https://docs.docker.com/build/bake/remote-definition/#combine-local-and-remote-bake-definitions

I will update the release notes.

@davhdavh
Copy link
Author

Thanks that work...

sinlov added a commit to bridgewwater/template-docker-runtime-alpine that referenced this issue Feb 3, 2025
feat #30

- from [docker/bake-action/issues/287](docker/bake-action#287)
- Add 'cwd://' prefix to docker_bake_config_file_path in echo statements
- Update 'files' input for buildx bake command to use 'cwd://' prefix
- Apply changes across multiple workflow templates and actual workflow files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants