Skip to content

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

@jonapich

Description

@jonapich

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions