Skip to content

Bake; placeholders or templating targets? #1150

@ciaranmcnulty

Description

@ciaranmcnulty

I have a job that builds a matrix of PHP versions, base distros (and some other stuff IRL). I want to combine it into one bake, but still source the versions from env vars. I'm not sure if there's a way to do this in bake, or if I need to generate HCL/JSON separately?

I could generate the default group pretty easily if I set an env var like PHP_VERSIONS=7,8 DISTROS =alpine,ubuntu:

variable PHP_VERSIONS {}
variable DISTROS {}

group "default" {
  targets = flatten(
    [for d in split(",", "${DISTROS}"):
      [for v in split(",", "${PHP_VERSIONS}"):
        "${d}-php-${v}"
      ]
    ]
  )
}

However I can't see how to avoid explicitly enumerating all the targets:

target "alpine-php-8" {}
[...etc...]

Ideally I'd have some way to template the targets, is there anything possible in bake's HCL?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions