Skip to content

bake: Resource interpolation on matrix target #2104

@jkroepke

Description

@jkroepke

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I'm trying to use Resource interpolation on my bake file together with an matrix build.

Expected behaviour

An valid bake output:

{
  "group": {
    "default": {
      "targets": [
        "windows"
      ]
    },
    "windows": {
      "targets": [
        "windows-ltsc2019",
        "windows-ltsc2022"
      ]
    }
  },
  "target": {
    "windows-ltsc2019": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "args": {
        "NANOSERVER_VERSION": "ltsc2019"
      },
      "tags": [
        "goldpinger:1.0.0",
        "goldpinger:latest"
      ],
      "target": "windows",
      "platforms": [
        "windows/amd64"
      ]
    },
    "windows-ltsc2022": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "args": {
        "NANOSERVER_VERSION": "ltsc2022"
      },
      "tags": [
        "goldpinger:1.0.0",
        "goldpinger:latest"
      ],
      "target": "windows",
      "platforms": [
        "windows/amd64"
      ]
    }
  }
}

Actual behaviour

Getting an error

docker-bake.hcl:15
--------------------
  13 |     
  14 |     target "windows" {
  15 | >>>   tags = target.docker-metadata-action.tags
  16 |     
  17 |       name = "windows-${version}"
--------------------
ERROR: docker-bake.hcl:15,16-39: Missing map element; This map does not have an element with the key "docker-metadata-action"., and 1 other diagnostic(s)

Buildx version

github.com/docker/buildx v0.11.2-desktop.5 f20ec1393426619870066baba9618cf999063886

Docker info

Client:
 Version:    24.0.6
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.5
    Path:     /Users/jok/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.22.0-desktop.2
    Path:     /Users/jok/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/jok/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/jok/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.8
    Path:     /Users/jok/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/jok/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/jok/.docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.0.7
    Path:     /Users/jok/.docker/cli-plugins/docker-scout

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.4.16-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 7.667GiB
 Name: docker-desktop
 ID: c71456c1-07af-4bf1-a675-42a0afde22b6
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  host.docker.internal:5000
  hubproxy.docker.internal:5555
  192.168.49.2:5000
  192.168.67.2:5000
  127.0.0.0/8
 Live Restore Enabled: false

Builders list

NAME/NODE         DRIVER/ENDPOINT  STATUS  BUILDKIT             PLATFORMS
dazzling_elion *  docker-container                              
  dazzling_elion0 desktop-linux    running v0.12.3              linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64, linux/arm/v7, linux/arm/v6
default           docker                                        
  default         default          running v0.11.6+616c3f613b54 linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64, linux/arm/v7, linux/arm/v6
desktop-linux     docker                                        
  desktop-linux   desktop-linux    running v0.11.6+616c3f613b54 linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64, linux/arm/v7, linux/arm/v6

Configuration

target "docker-metadata-action" {
  tags = ["goldpinger:1.0.0","goldpinger:latest"]
}

target "linux" {
  tags = target.docker-metadata-action.tags

  platforms = ["linux/amd64"]

  target = "linux"
}


target "windows" {
  tags = target.docker-metadata-action.tags

  name = "windows-${version}"
  matrix = {
    version = ["ltsc2019", "ltsc2022"]
  }
  platforms = ["windows/amd64"]

  target = "windows"
  args = {
    NANOSERVER_VERSION = version
  }
}

Build logs

N/A

Additional info

No response

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