docker: refactor cache handling in Docker bake configuration
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
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
- 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.
This commit is contained in:
@@ -13,11 +13,15 @@
|
||||
|
||||
Кэш registry (переменные bake):
|
||||
|
||||
- `git.shts.su/<owner>/evobgp-buildcache:go-buildcache`
|
||||
- `git.shts.su/<owner>/evobgp-buildcache:web-buildcache`
|
||||
- `git.shts.su/<owner>/evobgp-buildcache:go-buildcache` — **запись** только из target `go-build-all`
|
||||
- `git.shts.su/<owner>/evobgp-buildcache:web-buildcache` — **запись** только из target `web-build`
|
||||
|
||||
Остальные bake-target’ы только `cache-from` (чтение). Параллельный `cache-to` в один ref ломает manifest в registry (`content descriptor … not found`).
|
||||
|
||||
Локально BuildKit также кэширует `/go/pkg/mod` и `~/.cache/go-build` через `RUN --mount=type=cache`.
|
||||
|
||||
Если CI падает на «not found» после смены схемы кэша — один раз удалите теги `evobgp-buildcache:go-buildcache` и `:web-buildcache` в registry и пересоберите.
|
||||
|
||||
## Локальная сборка
|
||||
|
||||
Из корня репозитория:
|
||||
|
||||
@@ -32,7 +32,10 @@ function "go-cache-from" {
|
||||
result = notequal("", CACHE_REF_GO) ? ["type=registry,ref=${CACHE_REF_GO}"] : []
|
||||
}
|
||||
|
||||
function "go-cache-to" {
|
||||
# Экспорт кэша — только 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"] : []
|
||||
}
|
||||
@@ -42,7 +45,7 @@ function "web-cache-from" {
|
||||
result = notequal("", CACHE_REF_WEB) ? ["type=registry,ref=${CACHE_REF_WEB}"] : []
|
||||
}
|
||||
|
||||
function "web-cache-to" {
|
||||
function "web-cache-to-export" {
|
||||
params = []
|
||||
result = notequal("", CACHE_REF_WEB) ? ["type=registry,ref=${CACHE_REF_WEB},mode=max"] : []
|
||||
}
|
||||
@@ -76,7 +79,6 @@ target "go-deps" {
|
||||
target = "deps"
|
||||
platforms = ["linux/amd64"]
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
}
|
||||
|
||||
target "go-build-all" {
|
||||
@@ -88,7 +90,7 @@ target "go-build-all" {
|
||||
deps = "target:go-deps"
|
||||
}
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
cache-to = go-cache-to-export()
|
||||
}
|
||||
|
||||
target "go-birdc" {
|
||||
@@ -97,7 +99,6 @@ target "go-birdc" {
|
||||
target = "birdc"
|
||||
platforms = ["linux/amd64"]
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
}
|
||||
|
||||
target "_go-runtime" {
|
||||
@@ -109,7 +110,6 @@ target "_go-runtime" {
|
||||
build-all = "target:go-build-all"
|
||||
}
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
}
|
||||
|
||||
target "_go-runtime-birdc" {
|
||||
@@ -122,7 +122,6 @@ target "_go-runtime-birdc" {
|
||||
birdc = "target:go-birdc"
|
||||
}
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
}
|
||||
|
||||
function "image-tags" {
|
||||
@@ -187,7 +186,6 @@ target "evobgp-agent" {
|
||||
build-all = "target:go-build-all"
|
||||
}
|
||||
cache-from = go-cache-from()
|
||||
cache-to = go-cache-to()
|
||||
tags = image-tags("evobgp-agent")
|
||||
}
|
||||
|
||||
@@ -199,7 +197,6 @@ target "web-deps" {
|
||||
target = "deps"
|
||||
platforms = ["linux/amd64"]
|
||||
cache-from = web-cache-from()
|
||||
cache-to = web-cache-to()
|
||||
}
|
||||
|
||||
target "web-build" {
|
||||
@@ -211,7 +208,7 @@ target "web-build" {
|
||||
deps = "target:web-deps"
|
||||
}
|
||||
cache-from = web-cache-from()
|
||||
cache-to = web-cache-to()
|
||||
cache-to = web-cache-to-export()
|
||||
}
|
||||
|
||||
target "evobgp-web" {
|
||||
@@ -224,7 +221,6 @@ target "evobgp-web" {
|
||||
}
|
||||
args = { EVOBGP_UPSTREAM = "evobgp-api" }
|
||||
cache-from = web-cache-from()
|
||||
cache-to = web-cache-to()
|
||||
tags = image-tags("evobgp-web")
|
||||
}
|
||||
|
||||
@@ -238,7 +234,6 @@ target "evobgp-web-all" {
|
||||
}
|
||||
args = { EVOBGP_UPSTREAM = "evobgp-all" }
|
||||
cache-from = web-cache-from()
|
||||
cache-to = web-cache-to()
|
||||
tags = image-tags("evobgp-web-all")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user