Atm the bake definition needs to be opened to find out available targets. This is not practical and should be available through the cli.
Suggest to add a --targets or --list flag for bake cmd that would list the available targets.
Targets would need a description field to be displayed:
variable "GO_VERSION" {
default = "1.17"
}
target "_common" {
args = {
GO_VERSION = GO_VERSION
}
}
target "lint" {
description = "Validate using golangci-lint and yamllint linters"
inherits = ["_common"]
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
}
target "test" {
description = "Runs tests suite"
inherits = ["_common"]
target = "test-coverage"
output = ["./coverage"]
}
target "binaries" {
description = "Build binaries for the current platform"
inherits = ["_common"]
target = "binaries"
output = ["./bin"]
platforms = ["local"]
}
target "binaries-cross" {
description = "Build binaries for multi platform"
inherits = ["binaries"]
platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm/v6",
"linux/arm/v7",
"linux/arm64",
"linux/ppc64le",
"linux/riscv64",
"linux/s390x",
"windows/amd64",
"windows/arm64"
]
}
$ docker buildx bake --list
lint: Validate using golangci-lint and yamllint linters
test: Runs tests suite
binaries: Build binaries for the current platform
binaries-cross: Build binaries for multi platform
Targets that don't specify a description will not be displayed.
This flag cannot be used if a target is specified.
For compose it might be tricky as there is no such field in the compose spec that we could use. Maybe a comment can work in this case but not supported with JSON format:
# Build binaries for the current platform
target "binaries" {
inherits = ["_common"]
target = "binaries"
output = ["./bin"]
platforms = ["local"]
}
services:
binaries: # Build binaries for the current platform
build:
target: binaries
Or an extra arg to target:
target "binaries" "Build binaries for the current platform" {
inherits = ["_common"]
target = "binaries"
output = ["./bin"]
platforms = ["local"]
}
But again not suitable for a JSON representation as well as a compose file.
Open to suggestions.
Atm the bake definition needs to be opened to find out available targets. This is not practical and should be available through the cli.
Suggest to add a
--targetsor--listflag forbakecmd that would list the available targets.Targets would need a
descriptionfield to be displayed:Targets that don't specify a
descriptionwill not be displayed.This flag cannot be used if a target is specified.
For compose it might be tricky as there is no such field in the compose spec that we could use. Maybe a comment can work in this case but not supported with JSON format:
Or an extra arg to target:
But again not suitable for a JSON representation as well as a compose file.
Open to suggestions.