CI / changes (push) Successful in 7s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 1m29s
CI / docker-web (push) Failing after 15s
CI / docker-bird (push) Failing after 14s
CI / bird2 (push) Successful in 14s
CI / docker-go (push) Failing after 14s
Enhanced the CI workflow by adding support for docker-bake.hcl to streamline the building and pushing of Go images. Updated Go version to 1.24 and introduced caching for Go module dependencies. Refactored Dockerfiles for evobgp-agent, evobgp-web, and gobinary to utilize build stages more effectively, improving caching and build performance. Adjusted installation commands and entry points for better clarity and maintainability.
228 lines
4.9 KiB
HCL
228 lines
4.9 KiB
HCL
# Единая сборка образов EvoBGP для CI (buildx bake из deploy/docker/).
|
|
# Переменные: 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}"] : []
|
|
}
|
|
|
|
function "go-cache-to" {
|
|
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" {
|
|
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 = ["evobgp-web", "evobgp-web-all"]
|
|
}
|
|
|
|
# --- Go: go mod download → все cmd/* → birdc (один раз) → runtime-образы ---
|
|
|
|
target "go-deps" {
|
|
context = "../.."
|
|
dockerfile = "gobinary/Dockerfile"
|
|
target = "deps"
|
|
platforms = ["linux/amd64"]
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
}
|
|
|
|
target "go-build-all" {
|
|
context = "../.."
|
|
dockerfile = "gobinary/Dockerfile"
|
|
target = "build-all"
|
|
platforms = ["linux/amd64"]
|
|
contexts = {
|
|
deps = "target:go-deps"
|
|
}
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
}
|
|
|
|
target "go-birdc" {
|
|
context = "../.."
|
|
dockerfile = "gobinary/Dockerfile"
|
|
target = "birdc"
|
|
platforms = ["linux/amd64"]
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
}
|
|
|
|
target "_go-runtime" {
|
|
context = "../.."
|
|
dockerfile = "gobinary/Dockerfile"
|
|
target = "runtime"
|
|
platforms = ["linux/amd64"]
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
}
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
}
|
|
|
|
target "_go-runtime-birdc" {
|
|
context = "../.."
|
|
dockerfile = "gobinary/Dockerfile"
|
|
target = "runtime-birdc"
|
|
platforms = ["linux/amd64"]
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
birdc = "target:go-birdc"
|
|
}
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
}
|
|
|
|
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 = "evobgp-agent/Dockerfile"
|
|
platforms = ["linux/amd64"]
|
|
contexts = {
|
|
build-all = "target:go-build-all"
|
|
}
|
|
cache-from = go-cache-from()
|
|
cache-to = go-cache-to()
|
|
tags = image-tags("evobgp-agent")
|
|
}
|
|
|
|
# --- Web: npm ci (кэш) → build → nginx ---
|
|
|
|
target "web-deps" {
|
|
context = "../.."
|
|
dockerfile = "evobgp-web/Dockerfile"
|
|
target = "deps"
|
|
platforms = ["linux/amd64"]
|
|
cache-from = web-cache-from()
|
|
cache-to = web-cache-to()
|
|
}
|
|
|
|
target "evobgp-web" {
|
|
context = "../.."
|
|
dockerfile = "evobgp-web/Dockerfile"
|
|
platforms = ["linux/amd64"]
|
|
contexts = {
|
|
deps = "target:web-deps"
|
|
}
|
|
args = { EVOBGP_UPSTREAM = "evobgp-api" }
|
|
cache-from = web-cache-from()
|
|
cache-to = web-cache-to()
|
|
tags = image-tags("evobgp-web")
|
|
}
|
|
|
|
target "evobgp-web-all" {
|
|
inherits = ["evobgp-web"]
|
|
args = { EVOBGP_UPSTREAM = "evobgp-all" }
|
|
tags = image-tags("evobgp-web-all")
|
|
}
|
|
|
|
target "evobgp-bird2" {
|
|
context = "../.."
|
|
dockerfile = "bird2/Dockerfile"
|
|
platforms = ["linux/amd64"]
|
|
tags = image-tags("evobgp-bird2")
|
|
}
|