quality / commitlint (push) Skipped
quality / changes (push) Successful in 7s
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 28s
quality / web (push) Successful in 1m2s
quality / go (push) Successful in 1m6s
quality / bird2 (push) Successful in 17s
CD / quality (push) Successful in 3m12s
CD / publish (push) Successful in 5m44s
- Added `BUILDX_BAKE_FILE_RELATIVE_PATHS` environment variable to CI workflows to support relative paths in Docker bake commands. - Updated `docker-bake.hcl` comments to clarify context resolution from the current working directory. - Revised README documentation to reflect changes in context resolution and usage of the new environment variable.
349 lines
7.8 KiB
HCL
349 lines
7.8 KiB
HCL
# Единая сборка образов EvoBGP (buildx bake: -f deploy/docker/docker-bake.hcl).
|
|
# context = "../.." — корень репо. Bake резолвит context от cwd (не от HCL),
|
|
# поэтому вызов из deploy/docker/ либо BUILDX_BAKE_FILE_RELATIVE_PATHS=1.
|
|
# Переменные Bake читаются из окружения (см. docs.docker.com/build/bake/variables/).
|
|
|
|
variable "REGISTRY" {
|
|
default = "git.shx.one/evobgp"
|
|
}
|
|
|
|
variable "IMAGE_TAG" {
|
|
default = "latest"
|
|
}
|
|
|
|
variable "SHORT_SHA" {
|
|
default = "dev"
|
|
}
|
|
|
|
variable "SHA_FULL" {
|
|
default = ""
|
|
}
|
|
|
|
variable "VERSION" {
|
|
default = "dev"
|
|
}
|
|
|
|
variable "BUILD_TIME" {
|
|
default = ""
|
|
}
|
|
|
|
variable "CACHE_REF_GO" {
|
|
default = ""
|
|
}
|
|
|
|
variable "CACHE_REF_WEB" {
|
|
default = ""
|
|
}
|
|
|
|
variable "CACHE_REF_BIRDC" {
|
|
default = ""
|
|
}
|
|
|
|
variable "BASE_GOLANG" {
|
|
default = "docker.io/library/golang:1.24-alpine"
|
|
}
|
|
|
|
variable "BASE_DEBIAN" {
|
|
default = "docker.io/library/debian:bookworm-slim"
|
|
}
|
|
|
|
variable "BASE_DISTROLESS" {
|
|
default = "gcr.io/distroless/static-debian12:nonroot"
|
|
}
|
|
|
|
variable "BASE_NODE" {
|
|
default = "docker.io/library/node:22-alpine"
|
|
}
|
|
|
|
variable "BASE_NGINX" {
|
|
default = "docker.io/library/nginx:1.27-alpine"
|
|
}
|
|
|
|
variable "BASE_UBUNTU" {
|
|
default = "docker.io/library/ubuntu:noble"
|
|
}
|
|
|
|
function "go-cache-from" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_GO) ? ["type=registry,ref=${CACHE_REF_GO}"] : []
|
|
}
|
|
|
|
# Экспорт кэша — один writer на ref (параллельный cache-to в один ref ломает manifest).
|
|
function "go-cache-to-export" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_GO) ? ["type=registry,ref=${CACHE_REF_GO},mode=max"] : []
|
|
}
|
|
|
|
function "web-cache-from" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_WEB) ? ["type=registry,ref=${CACHE_REF_WEB}"] : []
|
|
}
|
|
|
|
function "web-cache-to-export" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_WEB) ? ["type=registry,ref=${CACHE_REF_WEB},mode=max"] : []
|
|
}
|
|
|
|
function "birdc-cache-from" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_BIRDC) ? ["type=registry,ref=${CACHE_REF_BIRDC}"] : []
|
|
}
|
|
|
|
function "birdc-cache-to-export" {
|
|
params = []
|
|
result = notequal("", CACHE_REF_BIRDC) ? ["type=registry,ref=${CACHE_REF_BIRDC},mode=max"] : []
|
|
}
|
|
|
|
group "default" {
|
|
targets = ["go-images", "web-images", "evobgp-bird2"]
|
|
}
|
|
|
|
group "go-images" {
|
|
targets = [
|
|
"evobgp-api",
|
|
"evobgp-all",
|
|
"evobgp-scheduler",
|
|
"evobgp-ingest",
|
|
"evobgp-render",
|
|
"evobgp-deploy",
|
|
"evobgp-node",
|
|
"evobgp-agent",
|
|
]
|
|
}
|
|
|
|
group "web-images" {
|
|
targets = ["evobgp-web", "evobgp-web-all"]
|
|
}
|
|
|
|
target "_common" {
|
|
platforms = ["linux/amd64"]
|
|
pull = false
|
|
}
|
|
|
|
target "_go-bases" {
|
|
args = {
|
|
BASE_GOLANG = BASE_GOLANG
|
|
BASE_DEBIAN = BASE_DEBIAN
|
|
BASE_DISTROLESS = BASE_DISTROLESS
|
|
}
|
|
}
|
|
|
|
# --- Go: go mod download → все cmd/* → birdc (один раз) → runtime-образы ---
|
|
|
|
target "go-deps" {
|
|
inherits = ["_common", "_go-bases"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/gobinary/Dockerfile"
|
|
target = "deps"
|
|
cache-from = go-cache-from()
|
|
}
|
|
|
|
target "go-build-all" {
|
|
inherits = ["_common", "_go-bases"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/gobinary/Dockerfile"
|
|
target = "build-all"
|
|
args = {
|
|
VERSION = VERSION
|
|
GIT_SHA = notequal("", SHA_FULL) ? SHA_FULL : SHORT_SHA
|
|
BUILD_TIME = BUILD_TIME
|
|
}
|
|
contexts = {
|
|
deps = "target:go-deps"
|
|
}
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to-export()
|
|
}
|
|
|
|
target "go-birdc" {
|
|
inherits = ["_common", "_go-bases"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/gobinary/Dockerfile"
|
|
target = "birdc"
|
|
cache-from = birdc-cache-from()
|
|
cache-to = birdc-cache-to-export()
|
|
}
|
|
|
|
target "_go-runtime" {
|
|
inherits = ["_common", "_go-bases"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/gobinary/Dockerfile"
|
|
target = "runtime"
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
}
|
|
cache-from = go-cache-from()
|
|
}
|
|
|
|
target "_go-runtime-birdc" {
|
|
inherits = ["_common", "_go-bases"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/gobinary/Dockerfile"
|
|
target = "runtime-birdc"
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
birdc = "target:go-birdc"
|
|
}
|
|
cache-from = concat(go-cache-from(), birdc-cache-from())
|
|
}
|
|
|
|
function "image-tags" {
|
|
params = [name]
|
|
result = concat(
|
|
notequal("", SHA_FULL) ? [
|
|
"${REGISTRY}/${name}:${IMAGE_TAG}",
|
|
"${REGISTRY}/${name}:${SHORT_SHA}",
|
|
"${REGISTRY}/${name}:sha-${SHA_FULL}",
|
|
] : [
|
|
"${REGISTRY}/${name}:${IMAGE_TAG}",
|
|
"${REGISTRY}/${name}:${SHORT_SHA}",
|
|
],
|
|
notequal(VERSION, "dev") && notequal(VERSION, "") ? [
|
|
"${REGISTRY}/${name}:v${VERSION}",
|
|
"${REGISTRY}/${name}:${VERSION}",
|
|
] : []
|
|
)
|
|
}
|
|
|
|
target "evobgp-api" {
|
|
inherits = ["_go-runtime-birdc"]
|
|
args = { BIN = "evobgp-api" }
|
|
tags = image-tags("evobgp-api")
|
|
}
|
|
|
|
target "evobgp-all" {
|
|
inherits = ["_go-runtime-birdc"]
|
|
args = { BIN = "evobgp-all" }
|
|
tags = image-tags("evobgp-all")
|
|
}
|
|
|
|
target "evobgp-scheduler" {
|
|
inherits = ["_go-runtime"]
|
|
args = { BIN = "evobgp-scheduler" }
|
|
tags = image-tags("evobgp-scheduler")
|
|
}
|
|
|
|
target "evobgp-ingest" {
|
|
inherits = ["_go-runtime"]
|
|
args = { BIN = "evobgp-ingest" }
|
|
tags = image-tags("evobgp-ingest")
|
|
}
|
|
|
|
target "evobgp-render" {
|
|
inherits = ["_go-runtime"]
|
|
args = { BIN = "evobgp-render" }
|
|
tags = image-tags("evobgp-render")
|
|
}
|
|
|
|
target "evobgp-deploy" {
|
|
inherits = ["_go-runtime"]
|
|
args = { BIN = "evobgp-deploy" }
|
|
tags = image-tags("evobgp-deploy")
|
|
}
|
|
|
|
target "evobgp-node" {
|
|
inherits = ["_go-runtime"]
|
|
args = { BIN = "evobgp-node" }
|
|
tags = image-tags("evobgp-node")
|
|
}
|
|
|
|
target "evobgp-bird2-base" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/bird2/Dockerfile"
|
|
target = "bird2-base"
|
|
args = {
|
|
BASE_UBUNTU = BASE_UBUNTU
|
|
}
|
|
}
|
|
|
|
target "evobgp-agent" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/evobgp-agent/Dockerfile"
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
bird2-base = "target:evobgp-bird2-base"
|
|
}
|
|
cache-from = go-cache-from()
|
|
tags = image-tags("evobgp-agent")
|
|
}
|
|
|
|
# --- Web ---
|
|
|
|
target "web-deps" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
|
|
target = "deps"
|
|
args = {
|
|
BASE_NODE = BASE_NODE
|
|
BASE_NGINX = BASE_NGINX
|
|
}
|
|
cache-from = web-cache-from()
|
|
}
|
|
|
|
target "web-build" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
|
|
target = "build"
|
|
args = {
|
|
BASE_NODE = BASE_NODE
|
|
BASE_NGINX = BASE_NGINX
|
|
}
|
|
contexts = {
|
|
deps = "target:web-deps"
|
|
}
|
|
cache-from = web-cache-from()
|
|
cache-to = web-cache-to-export()
|
|
}
|
|
|
|
target "evobgp-web" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
|
|
target = "web"
|
|
contexts = {
|
|
web-artifacts = "target:web-build"
|
|
}
|
|
args = {
|
|
EVOBGP_UPSTREAM = "evobgp-api"
|
|
BASE_NODE = BASE_NODE
|
|
BASE_NGINX = BASE_NGINX
|
|
}
|
|
cache-from = web-cache-from()
|
|
tags = image-tags("evobgp-web")
|
|
}
|
|
|
|
target "evobgp-web-all" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
|
|
target = "web"
|
|
contexts = {
|
|
web-artifacts = "target:web-build"
|
|
}
|
|
args = {
|
|
EVOBGP_UPSTREAM = "evobgp-all"
|
|
BASE_NODE = BASE_NODE
|
|
BASE_NGINX = BASE_NGINX
|
|
}
|
|
cache-from = web-cache-from()
|
|
tags = image-tags("evobgp-web-all")
|
|
}
|
|
|
|
target "evobgp-bird2" {
|
|
inherits = ["_common"]
|
|
context = "../.."
|
|
dockerfile = "deploy/docker/bird2/Dockerfile"
|
|
target = "bird2"
|
|
args = {
|
|
BASE_UBUNTU = BASE_UBUNTU
|
|
}
|
|
contexts = {
|
|
bird2-base = "target:evobgp-bird2-base"
|
|
}
|
|
tags = image-tags("evobgp-bird2")
|
|
}
|