docker / docker/buildx

Bake: allow inheriting from a map

Open
#3,557 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement status/triage
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

Description

Playing around with Docker Bake I found I needed to duplicate quite a bit of config as currently
https://github.com/docker/buildx/issues/1203 is not yet supported. However, even with that feature implemented, it would
be nice to inherit config from a map like, for example:

function "mkTarget" {
  params = [name]
  result = {
    tags = ["registry.example.com/${name}"]
    cache-from = [
      {
        type = "registry"
        ref = "registry.example.com/${name}:cache"
      }
    ]
    cache-to = [
      {
        type = "registry"
        ref = "registry.example.com/${name}:cache"
      }
    ]
  }
}

target "default" {
  inherits = [mkTarget("app")]
  context = "something"
  tags = ["registry.example.com/other:latest"]
}

This probably shouldn't use the inherits field, but this is just to give a general idea. It should probably not be
possible to merge the contents of the inherits field in the map due to potential infinite loops.

I'd be happy to look into implementing this if this is something that would be useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Docker Bake's handling of HCL functions, target inheritance, and map values, then review the related buildx issue #1203. Define how a target can inherit configuration from a function-returned map and ensure merging the map's inherits field cannot create infinite loops.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.