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

Using set overides rather than merges with array settings in docker-bake.hcl #295

Closed
3 tasks done
ncrmro opened this issue Jan 22, 2025 · 1 comment
Closed
3 tasks done

Comments

@ncrmro
Copy link

ncrmro commented Jan 22, 2025

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

It appears target sets are not merged with existing array and instead overide settings in the bake file.

Specifically cache-from's set in the action's set are not merged with cache froms in the the bake file

Expected behaviour

Given a docker-bake.hcl

target "foobar" {
  context = "."
  dockerfile = "Dockerfile"
  cache-release-from = [
    "type=registry,ref=ghcr.io/exampeorg/foobar:cache-release-development-staging"
  ]
}

And an action that sets cache-from, cache-to

      - name: Build and cache foobartarget
        uses: docker/bake-action@v6
        with:
          source: .
          targets: foobar
          files: docker-bake.hcl
          set: |
           foobar.cache-from=type=registry,ref=gghcr.io/exampeorg/foobar:cache-pr-development-PR-0000
            foobar.cache-to=type=registry,ref=ghcr.io/exampeorg/foobar:cache-pr-development-PR-0000,mode=max

Will result in a bake definition

  {
    "group": {
      "default": {
        "targets": [
          "foobar"
        ]
      }
    },
    "target": {
      "foobar": {
        "attest": [
          {
            "type": "provenance"
          }
        ],
        "context": ".",
        "dockerfile": "Dockerfile",
        "cache-from": [
          {
            "ref": "ghcr.io/exampeorg/foobar:cache-release-development-staging",
            "type": "registry"
          },
          {
            "ref": "ghcr.io/exampeorg/foobar:cache-pr-development-PR-0000",
            "type": "registry"
          }
        ],
        "cache-to": [
          {
            "mode": "max",
            "ref": "ghcr.io/exampeorg/foobar:cache-pr-development-PR-0000",
            "type": "registry"
          }
        ],
        "target": "foobar"
      }
    }
  }

Actual behaviour

I would expect this to merge and result in.

  {
    "group": {
      "default": {
        "targets": [
          "foobar"
        ]
      }
    },
    "target": {
      "foobar": {
        "attest": [
          {
            "type": "provenance"
          }
        ],
        "context": ".",
        "dockerfile": "Dockerfile",
        "cache-from": [
          {
            "ref": "ghcr.io/exampeorg/foobar:cache-pr-development-PR-0000",
            "type": "registry"
          }
        ],
        "cache-to": [
          {
            "mode": "max",
            "ref": "ghcr.io/exampeorg/foobar:cache-pr-development-PR-0000",
            "type": "registry"
          }
        ],
        "target": "foobar"
      }
    }
  }

### Repository URL

_No response_

### Workflow run URL

_No response_

### YAML workflow

```yaml
See expected behavor.

Workflow logs

No response

BuildKit logs


Additional info

No response

@crazy-max
Copy link
Member

Thanks for reporting, this is a bug in Buildx 0.20.0 that has been already addressed in docker/buildx#2944. Buildx 0.20.1 will go out today with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants