2021-08-16 23:07:43 -04:00
|
|
|
variable "GO_VERSION" {
|
2022-04-19 12:20:51 -04:00
|
|
|
default = "1.17.9"
|
2021-08-16 23:07:43 -04:00
|
|
|
}
|
2021-03-03 02:03:02 -05:00
|
|
|
variable "VERSION" {
|
|
|
|
default = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "USE_GLIBC" {
|
|
|
|
default = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "STRIP_TARGET" {
|
|
|
|
default = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
group "default" {
|
|
|
|
targets = ["binary"]
|
|
|
|
}
|
|
|
|
|
|
|
|
target "binary" {
|
|
|
|
target = "binary"
|
|
|
|
platforms = ["local"]
|
|
|
|
output = ["build"]
|
|
|
|
args = {
|
|
|
|
BASE_VARIANT = USE_GLIBC != "" ? "buster" : "alpine"
|
|
|
|
VERSION = VERSION
|
|
|
|
GO_STRIP = STRIP_TARGET
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
target "dynbinary" {
|
|
|
|
inherits = ["binary"]
|
|
|
|
args = {
|
|
|
|
GO_LINKMODE = "dynamic"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-05 16:16:05 -05:00
|
|
|
variable "GROUP_TOTAL" {
|
|
|
|
default = "1"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "GROUP_INDEX" {
|
|
|
|
default = "0"
|
|
|
|
}
|
|
|
|
|
|
|
|
function "platforms" {
|
2021-04-06 16:10:31 -04:00
|
|
|
params = []
|
|
|
|
result = ["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64"]
|
2021-03-05 16:16:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function "glen" {
|
|
|
|
params = [platforms, GROUP_TOTAL]
|
|
|
|
result = ceil(length(platforms)/GROUP_TOTAL)
|
|
|
|
}
|
|
|
|
|
2021-03-03 02:03:02 -05:00
|
|
|
target "_all_platforms" {
|
2021-04-06 16:10:31 -04:00
|
|
|
platforms = slice(platforms(), GROUP_INDEX*glen(platforms(), GROUP_TOTAL),min(length(platforms()), (GROUP_INDEX+1)*glen(platforms(), GROUP_TOTAL)))
|
2021-03-03 02:03:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
target "cross" {
|
|
|
|
inherits = ["binary", "_all_platforms"]
|
|
|
|
}
|
|
|
|
|
|
|
|
target "dynbinary-cross" {
|
|
|
|
inherits = ["dynbinary", "_all_platforms"]
|
|
|
|
}
|