uci-docker-build/docker-bake.hcl

94 lines
1.9 KiB
HCL
Raw Normal View History

# variables
variable "TAG" {
default = "latest"
}
variable "LINUX_DISTRO" {
// default = "alpine"
}
variable "BUILD_DIR" {
default = ""
}
variable "IMAGE_NAME" {
// default = "alpine"
}
variable "BASE_IMAGE" {
// default = "alpine"
}
variable "KEEP" {
default = ""
}
variable "SYSADMIN_PW" {
default = ""
}
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}"
SCRIPTS = "${BUILD_DIR}"
KEEP = "${KEEP}"
SYSADMIN_PW = "${SYSADMIN_PW}"
}
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}/" : "")
// ]
// }