Files
EvoBGP/deploy/docker/docker-bake.hcl
T
Denozordec 5e59a1c334
CI / changes (push) Successful in 7s
CI / openapi (push) Has been skipped
CI / go (push) Has been skipped
CI / docker-web (push) Failing after 15s
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 14s
CI / docker-go (push) Successful in 2m36s
docker: refactor cache handling in Docker bake configuration
- Renamed cache functions for Go and web targets to clarify their purpose and prevent race conditions during parallel builds.
- Updated targets to use the new cache export functions, ensuring proper cache management.
- Revised README to reflect changes in cache usage and provide guidance on resolving potential CI issues related to cache schema changes.
2026-05-19 14:12:10 +07:00

246 lines
5.8 KiB
HCL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Единая сборка образов EvoBGP (buildx bake: -f deploy/docker/docker-bake.hcl).
# context = "../.." — корень репозитория (относительно этого файла).
# dockerfile — путь от корня репозитория (относительно context).
# Переменные: REGISTRY, IMAGE_TAG, CACHE_REF_GO, CACHE_REF_WEB
variable "REGISTRY" {
default = "git.shts.su/evobgp"
}
variable "IMAGE_TAG" {
default = "latest"
}
variable "SHORT_SHA" {
default = "dev"
}
variable "SHA_FULL" {
default = ""
}
variable "CACHE_REF_GO" {
default = ""
}
variable "CACHE_REF_WEB" {
default = ""
}
function "go-cache-from" {
params = []
result = notequal("", CACHE_REF_GO) ? ["type=registry,ref=${CACHE_REF_GO}"] : []
}
# Экспорт кэша — только go-build-all / web-build (один writer на ref).
# Несколько target с cache-to в один ref и mode=max дают гонку в registry
# (content descriptor not found при параллельном bake).
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"] : []
}
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 = ["web-deps", "web-build", "evobgp-web", "evobgp-web-all"]
}
# --- Go: go mod download → все cmd/* → birdc (один раз) → runtime-образы ---
target "go-deps" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "deps"
platforms = ["linux/amd64"]
cache-from = go-cache-from()
}
target "go-build-all" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "build-all"
platforms = ["linux/amd64"]
contexts = {
deps = "target:go-deps"
}
cache-from = go-cache-from()
cache-to = go-cache-to-export()
}
target "go-birdc" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "birdc"
platforms = ["linux/amd64"]
cache-from = go-cache-from()
}
target "_go-runtime" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "runtime"
platforms = ["linux/amd64"]
contexts = {
build-all = "target:go-build-all"
}
cache-from = go-cache-from()
}
target "_go-runtime-birdc" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "runtime-birdc"
platforms = ["linux/amd64"]
contexts = {
build-all = "target:go-build-all"
birdc = "target:go-birdc"
}
cache-from = go-cache-from()
}
function "image-tags" {
params = [name]
result = notequal("", SHA_FULL) ? [
"${REGISTRY}/${name}:${IMAGE_TAG}",
"${REGISTRY}/${name}:${SHORT_SHA}",
"${REGISTRY}/${name}:sha-${SHA_FULL}",
] : [
"${REGISTRY}/${name}:${IMAGE_TAG}",
"${REGISTRY}/${name}:${SHORT_SHA}",
]
}
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-agent" {
context = "../.."
dockerfile = "deploy/docker/evobgp-agent/Dockerfile"
platforms = ["linux/amd64"]
contexts = {
build-all = "target:go-build-all"
}
cache-from = go-cache-from()
tags = image-tags("evobgp-agent")
}
# --- Web: npm ci (кэш) → build → nginx ---
target "web-deps" {
context = "../.."
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
target = "deps"
platforms = ["linux/amd64"]
cache-from = web-cache-from()
}
target "web-build" {
context = "../.."
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
target = "build"
platforms = ["linux/amd64"]
contexts = {
deps = "target:web-deps"
}
cache-from = web-cache-from()
cache-to = web-cache-to-export()
}
target "evobgp-web" {
context = "../.."
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
target = "web"
platforms = ["linux/amd64"]
contexts = {
web-artifacts = "target:web-build"
}
args = { EVOBGP_UPSTREAM = "evobgp-api" }
cache-from = web-cache-from()
tags = image-tags("evobgp-web")
}
target "evobgp-web-all" {
context = "../.."
dockerfile = "deploy/docker/evobgp-web/Dockerfile"
target = "web"
platforms = ["linux/amd64"]
contexts = {
web-artifacts = "target:web-build"
}
args = { EVOBGP_UPSTREAM = "evobgp-all" }
cache-from = web-cache-from()
tags = image-tags("evobgp-web-all")
}
target "evobgp-bird2" {
context = "../.."
dockerfile = "deploy/docker/bird2/Dockerfile"
platforms = ["linux/amd64"]
tags = image-tags("evobgp-bird2")
}