Files
EvoBGP/deploy/docker/docker-bake.hcl
T
Denozordec 7d52a4af63
CI / changes (push) Successful in 6s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 29s
CI / docker-web (push) Successful in 1m30s
CI / docker-bird (push) Successful in 43s
CI / bird2 (push) Successful in 15s
CI / docker-go (push) Successful in 3m0s
refactor: update Docker build context and paths in CI configuration and documentation
Modified the CI workflow to include the `--allow=fs.read` flag for Docker build commands, allowing access to the repository context. Updated the `docker-bake.hcl` file to reflect the correct paths for Dockerfiles, ensuring consistency with the new structure. Adjusted the README to clarify the changes in build commands and paths, enhancing overall documentation accuracy.
2026-05-19 10:56:25 +07:00

230 lines
5.3 KiB
HCL

# Единая сборка образов 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}"] : []
}
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 = "deploy/docker/gobinary/Dockerfile"
target = "deps"
platforms = ["linux/amd64"]
cache-from = go-cache-from()
cache-to = go-cache-to()
}
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()
}
target "go-birdc" {
context = "../.."
dockerfile = "deploy/docker/gobinary/Dockerfile"
target = "birdc"
platforms = ["linux/amd64"]
cache-from = go-cache-from()
cache-to = go-cache-to()
}
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()
cache-to = go-cache-to()
}
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()
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 = "deploy/docker/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 = "deploy/docker/evobgp-web/Dockerfile"
target = "deps"
platforms = ["linux/amd64"]
cache-from = web-cache-from()
cache-to = web-cache-to()
}
target "evobgp-web" {
context = "../.."
dockerfile = "deploy/docker/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 = "deploy/docker/bird2/Dockerfile"
platforms = ["linux/amd64"]
tags = image-tags("evobgp-bird2")
}