buildx icon indicating copy to clipboard operation
buildx copied to clipboard

bake: set input:context for remote builds

Open crazy-max opened this issue 2 months ago • 0 comments

~needs #3459~

Atm remote Git URL get lost as we are creating a state input when a subdir is used. In such case we can set Path with the resolved context URL for the target and pass it as a input:context frontend attribute.

This also fixes the canonical output of remote bake definition to set context accordingly. Before it was not displaying the right context if there was a subdir.

Before:

$ docker buildx bake https://github.com/dockersamples/labspace-infra.git interface --print
{
  "group": {
    "default": {
      "targets": [
        "interface"
      ]
    }
  },
  "target": {
    "interface": {
      "attest": [
        {
          "mode": "max",
          "type": "provenance"
        },
        {
          "type": "sbom"
        }
      ],
      "context": "components/interface",
      "dockerfile": "Dockerfile",
      "tags": [
        "dockersamples/labspace-interface:latest"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64"
      ]
    }
  }
}

Now:

$ docker buildx bake https://github.com/dockersamples/labspace-infra.git interface --print
#0 building with "default" instance using docker driver

#1 [internal] load git source https://github.com/dockersamples/labspace-infra.git
#1 0.515 ref: refs/heads/main   HEAD
#1 0.515 a0e670182ef24ae03d0c50b81dfee14b8c5f6295       HEAD
#1 0.887 a0e670182ef24ae03d0c50b81dfee14b8c5f6295       refs/heads/main
#1 CACHED
{
  "group": {
    "default": {
      "targets": [
        "interface"
      ]
    }
  },
  "target": {
    "interface": {
      "attest": [
        {
          "mode": "max",
          "type": "provenance"
        },
        {
          "type": "sbom"
        }
      ],
      "context": "https://github.com/dockersamples/labspace-infra.git#:components/interface",
      "dockerfile": "Dockerfile",
      "tags": [
        "dockersamples/labspace-interface:latest"
      ],
      "platforms": [
        "linux/amd64",
        "linux/arm64"
      ]
    }
  }
}

crazy-max avatar Oct 08 '25 13:10 crazy-max