2022-10-20 18:48:17 -07:00
|
|
|
# variables
|
|
|
|
variable "TAG" {
|
|
|
|
default = "latest"
|
|
|
|
}
|
|
|
|
variable "LINUX_DISTRO" {
|
2024-09-15 18:47:22 -07:00
|
|
|
default = "alpine"
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
|
|
|
variable "IMAGE_NAME" {
|
2024-09-15 18:47:22 -07:00
|
|
|
default = "alpine"
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
|
|
|
variable "BASE_IMAGE" {
|
2024-09-15 18:47:22 -07:00
|
|
|
default = "alpine"
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
2023-04-22 08:19:45 -07:00
|
|
|
variable "VERBOSE" {
|
2023-01-21 22:22:41 -08:00
|
|
|
default = ""
|
|
|
|
}
|
2023-04-22 08:19:45 -07:00
|
|
|
variable "REBUILD" {
|
2023-04-14 21:27:40 -07:00
|
|
|
default = ""
|
|
|
|
}
|
2023-04-01 07:17:43 -07:00
|
|
|
variable "ARCH" {
|
|
|
|
default = ""
|
|
|
|
}
|
2022-10-20 18:48:17 -07:00
|
|
|
function "tag" {
|
|
|
|
params = [suffix]
|
2023-04-14 21:27:40 -07:00
|
|
|
result = [format("${IMAGE_NAME}%s:${TAG}", notequal("${ARCH}", suffix) ? "-${suffix}" : "")]
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
|
|
|
# groups
|
|
|
|
group "dev" {
|
2023-04-01 07:17:43 -07:00
|
|
|
targets = ["${ARCH}"]
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
|
|
|
group "default" {
|
2023-04-01 07:17:43 -07:00
|
|
|
targets = ["${ARCH}"]
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
2023-04-14 21:27:40 -07:00
|
|
|
group "multi" {
|
2022-10-20 18:48:17 -07:00
|
|
|
targets = [
|
2023-04-01 07:17:43 -07:00
|
|
|
"amd64",
|
|
|
|
"arm64"
|
2022-10-20 18:48:17 -07:00
|
|
|
]
|
|
|
|
}
|
|
|
|
# intended for use with default local docker builder
|
|
|
|
# uses 'dev' group in docker-bake.hcl
|
2023-04-14 21:27:40 -07:00
|
|
|
# assume dev and default build for architecture of local machine
|
2023-04-01 07:17:43 -07:00
|
|
|
target "amd64" {
|
2022-10-20 18:48:17 -07:00
|
|
|
context = "."
|
|
|
|
dockerfile = "Dockerfile"
|
|
|
|
args = {
|
2023-03-22 09:10:54 -07:00
|
|
|
LINUX_DISTRO = "${LINUX_DISTRO}"
|
|
|
|
BASE_IMAGE = "${BASE_IMAGE}"
|
|
|
|
TAG = "${TAG}"
|
2023-04-14 21:27:40 -07:00
|
|
|
VERBOSE = "${VERBOSE}"
|
2023-04-22 08:19:45 -07:00
|
|
|
REBUILD = "${REBUILD}"
|
2022-10-20 18:48:17 -07:00
|
|
|
}
|
2023-04-14 21:27:40 -07:00
|
|
|
tags = tag("amd64")
|
2022-10-20 18:48:17 -07:00
|
|
|
platforms = ["linux/amd64"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# intended for use with default docker driver on an arm64 machine
|
|
|
|
# use with 'arm' group
|
2023-04-01 07:17:43 -07:00
|
|
|
target "arm64" {
|
|
|
|
inherits = ["amd64"]
|
2022-10-20 18:48:17 -07:00
|
|
|
tags = tag("arm64")
|
|
|
|
platforms = ["linux/arm64"]
|
|
|
|
}
|
|
|
|
|
2023-04-14 21:27:40 -07:00
|
|
|
# must use with docker-container driver for multiarch image publishment to registry
|
|
|
|
# uses 'publish' group in docker-bake.hcl
|
|
|
|
target "publish" {
|
2023-04-01 07:17:43 -07:00
|
|
|
inherits = ["amd64"]
|
2023-04-14 21:27:40 -07:00
|
|
|
tags = ["${IMAGE_NAME}:${TAG}"]
|
2022-10-20 18:48:17 -07:00
|
|
|
platforms = ["linux/amd64", "linux/arm64"]
|
|
|
|
output = ["type=registry"]
|
2023-04-14 21:27:40 -07:00
|
|
|
}
|