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

Allow specifying additional configuration files to be merged on top of auto-detected configuration files #2873

Open
jonapich opened this issue Dec 19, 2024 · 1 comment
Labels
kind/enhancement New feature or request status/triage

Comments

@jonapich
Copy link
Contributor

jonapich commented Dec 19, 2024

Description

Context: I am writing tooling that handles the auth-build-push of container images for other teams to use. Users are allowed to use any of the supported config files.

Use case: The tooling needs to override some attributes like tags, outputs and annotations. To do this I would prefer writing a JSON file on disk with the overrides, and then provide it to bake:

docker buildx bake --file <autodetected-files?> --file tooling-overrides.json

Problem: As I tried to express in the line above, the usage of --file to override implies that the user's --file is specified. There is therefore no way to use the automatic config file detection and specify an additional file to consider at the end.

Something like this would be useful:

docker buildx bake --with-overrides tooling-overrides.json

Another subtle problem is that the .json files typically take precedence over the .hcl files:

  • (...)
  • docker-bake.json
  • docker-bake.override.json
  • docker-bake.hcl
  • docker-bake.override.hcl

Most people here use docker-bake.hcl, leaving only docker-bake.override.hcl as the file I could use for this purpose. Unfortunately, I don't have an HCL parser in my context (it's a small actions/github-script javascript snippet that uses the builtin libraries), so I was hoping to output a JSON file instead. Since the "override" json is read before the normal "hcl" bake file, this solution won't work.

If this order was slightly altered, then it would feel natural for tooling to produce an "override" file:

  • (...)
  • docker-bake.json
  • docker-bake.hcl
  • docker-bake.override.json
  • docker-bake.override.hcl

Even though the order of precedence is very well documented, it does feel odd that some "override" files are then overridden by non-override files (e.g.: docker-bake.override.json is overridden by docker-bake.hcl which isn't what one would expect before reading the docs.)

Current approach: I am using the --set CLI argument instead of a file-based override. However this doesn't feel as clean and I have to be careful about quoting/escaping.

@jonapich jonapich added kind/enhancement New feature or request status/triage labels Dec 19, 2024
@tonistiigi
Copy link
Member

Changing the loading position of docker-bake.override.json seems ok to me. I don't think we want to add a new flag for multiple ways to load files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request status/triage
Projects
None yet
Development

No branches or pull requests

2 participants