docker / metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
https://github.com/marketplace/actions/docker-metadata-action
Apache License 2.0
911 stars 118 forks source link

bake: set cwd:// prefix for bake files path #370

Closed crazy-max closed 10 months ago

crazy-max commented 10 months ago

follow-up https://github.com/docker/bake-action/pull/181#discussion_r1432700454

olee commented 9 months ago

I don't know why, but this change seems to break some builds - and that quite inconsistently. In my case I have a matrix build and it actually happened to me, that one of the meta files was generated with cwd:// in the path which caused that one to fail, whereas another one didn't get the cwd and ran just fine:

Matrix job 1 generates this command: /usr/bin/docker buildx bake --file docker-compose.yaml --file docker-compose.bake.yaml --file docker-bake.gha.hcl --file cwd:///home/runner/work/_temp/docker-actions-toolkit-A8BM8v/docker-metadata-action-bake.json --metadata-file /home/runner/work/_temp/docker-actions-toolkit-oxkS5j/metadata-file --pull --push gha_keycloak-config --print

Matrix job 2 generates this command: /usr/bin/docker buildx bake --file docker-compose.prod.yaml --file docker-compose.bake.yaml --file docker-bake.gha.hcl --file /home/runner/work/_temp/docker-actions-toolkit-bsKuk7/docker-metadata-action-bake.json --metadata-file /home/runner/work/_temp/docker-actions-toolkit-dPbXcm/metadata-file --pull --push gha_migration-runner --print

Both seem to load the file, but for some reason it seems that in the case with cwd:// the file is interpreted before the other specified bake files instead of afterwards.

I notice this because in docker-bake.gha.hcl I have target "docker-metadata-action" { tags = ["!tag-not-set!"] } which will cause to build to fail if not overwritten. When cwd:// is present in the path, this tag is not overwritten, but if the path is without cwd it works just fine.

Any idea what could be causing this or is there any way to remove that prefix?

crazy-max commented 9 months ago

@olee

which caused that one to fail, whereas another one didn't get the cwd and ran just fine:

The change of behavior might be related to GitHub slowly provisioning runners with latest Docker 25 which now installs Buildx 0.12. Can you open an issue with your workflow, logs and link to your repo if possible to take a look?

I notice this because in docker-bake.gha.hcl I have target "docker-metadata-action" { tags = ["!tag-not-set!"] } which will cause to build to fail if not overwritten. When cwd:// is present in the path, this tag is not overwritten, but if the path is without cwd it works just fine.

Hum that doesn't sound right indeed. It should merge files in the specified order. Can you open another issue on https://github.com/docker/buildx this time with a minimal repro?