CI refactor & Add SLSA provenance for release and docker image (#1093)

This commit is contained in:
vickunwu
2025-02-01 17:19:08 +08:00
committed by GitHub
parent 337f4b3a48
commit 84be15b0c2
4 changed files with 634 additions and 0 deletions

50
docker-bake.hcl Normal file
View File

@@ -0,0 +1,50 @@
variable "TARGET" {
default = "$TARGET"
}
variable "GHCR_REPO" {
default = "$GHCR_REPO"
}
variable "BUILD_ENV" {
default = "$BUILD_ENV"
}
variable "SUFFIX" {
default = "$SUFFIX"
}
variable "DOCKER_PLATFORM" {
default = "$DOCKER_PLATFORM"
}
target "docker-metadata-action" {}
target "build" {
secret = [
"type=env,id=ACTIONS_CACHE_URL",
"type=env,id=ACTIONS_RUNTIME_TOKEN"
]
args = {
TARGET = "${TARGET}"
BUILD_ENV = equal("", "${BUILD_ENV}") ? null : "${BUILD_ENV}"
}
target = "binaries"
cache-from = [
"type=registry,ref=${GHCR_REPO}-buildcache:${TARGET}"
]
cache-to = [
"type=registry,ref=${GHCR_REPO}-buildcache:${TARGET},mode=max,compression=zstd,compression-level=9,force-compression=true,oci-mediatypes=true,image-manifest=false"
]
context = "./"
dockerfile = "Dockerfile.build"
output = ["./artifact"]
}
target "image" {
inherits = ["build","docker-metadata-action"]
cache-to = [""]
cache-from = [
"type=registry,ref=${GHCR_REPO}-buildcache:${TARGET}"
]
target = equal("", "${SUFFIX}") ? "gnu" : "musl"
platforms = [
"${DOCKER_PLATFORM}"
]
output = [
""
]
}