Skip to content

Overriding variable values at the target level in the bakefile #3271

Open
@guilhemCap

Description

@guilhemCap

Description

I'd like to do the following:

Creating a common target and variables, affect it different keys like:

variable "IMAGE" {}
variable "TAG" {}

target "__common__" {
  tags = [
    "ghcr.io/OWNER/${IMAGE}:latest",
    "ghcr.io/OWNER/${IMAGE}:${TAG}"
  ]
  cache-to = [
    {
      type  = "registry"
      ref   = "ghcr.io/OWNER/${IMAGE}:cache"
    }
  ]
  cache-from = [
    {
      type  = "registry"
      ref   = "ghcr.io/OWNER/${IMAGE}:cache"
    }
  ]
}

And then override it at the target level like this:

target "target-1" {
  inherits = ["_common"]
  context = "./docker"
  dockerfile = "Dockerfile"
  vars= {
    image-name = "target-1"
  }
}

I am not sure this feature exists, the current workaround might be to use a matrix strategy and no common target

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