82 lines
1.7 KiB
HCL
82 lines
1.7 KiB
HCL
|
# variables
|
||
|
variable "TAG" {
|
||
|
default = "latest"
|
||
|
}
|
||
|
variable "LINUX_DISTRO" {
|
||
|
default = "alpine"
|
||
|
}
|
||
|
variable "IMAGE_NAME" {
|
||
|
default = "alpine"
|
||
|
}
|
||
|
variable "BASE_IMAGE" {
|
||
|
default = "alpine"
|
||
|
}
|
||
|
|
||
|
function "tag" {
|
||
|
params = [suffix]
|
||
|
result = [format("${IMAGE_NAME}%s:${TAG}", notequal("", suffix) ? "-${suffix}" : "")]
|
||
|
}
|
||
|
# groups
|
||
|
group "dev" {
|
||
|
targets = ["amd"]
|
||
|
}
|
||
|
group "default" {
|
||
|
targets = ["amd"]
|
||
|
}
|
||
|
group "deploy" {
|
||
|
targets = ["multi"]
|
||
|
}
|
||
|
group "private" {
|
||
|
targets = [
|
||
|
"amd",
|
||
|
"arm"
|
||
|
]
|
||
|
}
|
||
|
# intended for use with default local docker builder
|
||
|
# uses 'dev' group in docker-bake.hcl
|
||
|
# assume dev machine is amd64 machine
|
||
|
target "amd" {
|
||
|
context = "."
|
||
|
dockerfile = "Dockerfile"
|
||
|
args = {
|
||
|
LINUX_DISTRO = "${LINUX_DISTRO}"
|
||
|
BASE_IMAGE = "${BASE_IMAGE}"
|
||
|
TAG = "${TAG}"
|
||
|
}
|
||
|
tags = tag("")
|
||
|
platforms = ["linux/amd64"]
|
||
|
}
|
||
|
|
||
|
# intended for use with default docker driver on an arm64 machine
|
||
|
# use with 'arm' group
|
||
|
target "arm" {
|
||
|
inherits = ["amd"]
|
||
|
tags = tag("arm64")
|
||
|
platforms = ["linux/arm64"]
|
||
|
}
|
||
|
|
||
|
# must use with docker-container driver for multiarch image deployment to registry
|
||
|
# uses 'deploy' group in docker-bake.hcl
|
||
|
target "multi" {
|
||
|
inherits = ["amd"]
|
||
|
tags = tag("")
|
||
|
platforms = ["linux/amd64", "linux/arm64"]
|
||
|
output = ["type=registry"]
|
||
|
}
|
||
|
|
||
|
|
||
|
// variable "RUSER" {
|
||
|
// default = ""
|
||
|
// }
|
||
|
// function "user" {
|
||
|
// params = []
|
||
|
// result = [notequal("", RUSER) ? "${RUSER}/" : ""]
|
||
|
// }
|
||
|
|
||
|
// function "tagamd" {
|
||
|
// params = []
|
||
|
// result = [
|
||
|
// format("%s${LINUX_DISTRO}:${TAG}", notequal("", RUSER) ? "${RUSER}/" : ""),
|
||
|
// format("%s${LINUX_DISTRO}-amd64:${TAG}", notequal("", RUSER) ? "${RUSER}/" : "")
|
||
|
// ]
|
||
|
// }
|