Files
noteflow/docker-bake.hcl

298 lines
7.6 KiB
HCL

# docker-bake.hcl
# Docker Buildx Bake configuration for NoteFlow
#
# Usage:
# docker buildx bake # Build default targets (CPU server)
# docker buildx bake prod # Build all production images
# docker buildx bake dev # Build all dev images
# docker buildx bake server # Build CPU server only
# docker buildx bake server-gpu # Build CUDA GPU server only
# docker buildx bake server-rocm # Build ROCm GPU server only
# docker buildx bake --print # Show build plan without building
# docker buildx bake --push prod # Build and push production images
#
# Registry configuration:
# REGISTRY=git.baked.rocks/vasceannie docker buildx bake --push prod
# =============================================================================
# Variables
# =============================================================================
variable "REGISTRY" {
default = "git.baked.rocks/vasceannie"
}
variable "IMAGE_NAME" {
default = "noteflow"
}
variable "TAG" {
default = "latest"
}
variable "PYTHON_VERSION" {
default = "3.12"
}
variable "CUDA_VERSION" {
default = "12.4.1"
}
variable "ROCM_VERSION" {
default = "6.4.1"
}
variable "ROCM_PYTORCH_RELEASE" {
default = "2.6.0"
}
variable "SPACY_MODEL_URL" {
default = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"
}
# =============================================================================
# Functions - Single repo tagging scheme
# =============================================================================
# Base image path: REGISTRY/IMAGE_NAME
function "image_base" {
params = []
result = REGISTRY != "" ? "${REGISTRY}/${IMAGE_NAME}" : IMAGE_NAME
}
# CPU server tags: :TAG and :latest
function "tags_cpu" {
params = []
result = TAG == "latest" ? [
"${image_base()}:latest"
] : [
"${image_base()}:${TAG}",
"${image_base()}:latest"
]
}
# GPU (CUDA) server tags: :TAG-gpu and :latest-gpu
function "tags_gpu" {
params = []
result = TAG == "latest" ? [
"${image_base()}:latest-gpu"
] : [
"${image_base()}:${TAG}-gpu",
"${image_base()}:latest-gpu"
]
}
# ROCm server tags: :TAG-rocm and :latest-rocm
function "tags_rocm" {
params = []
result = TAG == "latest" ? [
"${image_base()}:latest-rocm"
] : [
"${image_base()}:${TAG}-rocm",
"${image_base()}:latest-rocm"
]
}
# Dev tags (not published, local only)
function "tags_dev" {
params = [suffix]
result = ["${image_base()}:dev${suffix}"]
}
# =============================================================================
# Groups - Organized by use case
# =============================================================================
group "default" {
targets = ["server"]
}
# Production images (publishable)
group "prod" {
targets = ["server", "server-gpu", "server-rocm"]
}
# Development images (local only)
group "dev" {
targets = ["server-dev", "server-gpu-dev", "server-rocm-dev"]
}
# All server variants
group "servers" {
targets = ["server", "server-gpu", "server-rocm"]
}
# GPU variants only
group "servers-gpu" {
targets = ["server-gpu", "server-rocm"]
}
# CI targets with GHA caching
group "ci" {
targets = ["server-ci", "server-gpu-ci", "server-rocm-ci"]
}
# =============================================================================
# Base Targets (inherited)
# =============================================================================
target "_common" {
context = "."
labels = {
"org.opencontainers.image.source" = "https://github.com/noteflow/noteflow"
"org.opencontainers.image.vendor" = "NoteFlow"
}
}
target "_server-common" {
inherits = ["_common"]
dockerfile = "docker/server.Dockerfile"
args = {
PYTHON_VERSION = PYTHON_VERSION
SPACY_MODEL_URL = SPACY_MODEL_URL
}
cache-from = [
"type=registry,ref=${image_base()}:cache"
]
cache-to = [
"type=inline"
]
}
target "_server-gpu-common" {
inherits = ["_common"]
dockerfile = "docker/server-gpu.Dockerfile"
args = {
PYTHON_VERSION = PYTHON_VERSION
CUDA_VERSION = CUDA_VERSION
SPACY_MODEL_URL = SPACY_MODEL_URL
}
cache-from = [
"type=registry,ref=${image_base()}:cache-gpu"
]
cache-to = [
"type=inline"
]
}
target "_server-rocm-common" {
inherits = ["_common"]
dockerfile = "docker/Dockerfile.rocm"
args = {
ROCM_VERSION = ROCM_VERSION
ROCM_PYTORCH_RELEASE = ROCM_PYTORCH_RELEASE
SPACY_MODEL_URL = SPACY_MODEL_URL
}
cache-from = [
"type=registry,ref=${image_base()}:cache-rocm"
]
cache-to = [
"type=inline"
]
}
# =============================================================================
# Production Server Targets
# =============================================================================
# CPU server (multi-arch: amd64 + arm64)
target "server" {
inherits = ["_server-common"]
target = "server"
tags = tags_cpu()
platforms = ["linux/amd64", "linux/arm64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server"
"org.opencontainers.image.description" = "NoteFlow gRPC server - CPU multi-arch build"
}
}
# CUDA GPU server (amd64 only)
target "server-gpu" {
inherits = ["_server-gpu-common"]
target = "server"
tags = tags_gpu()
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server (GPU)"
"org.opencontainers.image.description" = "NoteFlow gRPC server - NVIDIA CUDA GPU build"
"ai.noteflow.cuda.version" = CUDA_VERSION
}
}
# ROCm GPU server (amd64 only)
target "server-rocm" {
inherits = ["_server-rocm-common"]
target = "server"
tags = tags_rocm()
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server (ROCm)"
"org.opencontainers.image.description" = "NoteFlow gRPC server - AMD ROCm GPU build"
"ai.noteflow.rocm.version" = ROCM_VERSION
}
}
# =============================================================================
# Development Server Targets (local only, not published)
# =============================================================================
# CPU dev server
target "server-dev" {
inherits = ["_server-common"]
target = "dev"
tags = tags_dev("")
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Dev"
"org.opencontainers.image.description" = "NoteFlow development server with all extras"
}
}
# CUDA GPU dev server
target "server-gpu-dev" {
inherits = ["_server-gpu-common"]
target = "dev"
tags = tags_dev("-gpu")
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Dev (GPU)"
"org.opencontainers.image.description" = "NoteFlow development server - NVIDIA CUDA GPU build"
"ai.noteflow.cuda.version" = CUDA_VERSION
}
}
# ROCm GPU dev server
target "server-rocm-dev" {
inherits = ["_server-rocm-common"]
target = "dev"
tags = tags_dev("-rocm")
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Dev (ROCm)"
"org.opencontainers.image.description" = "NoteFlow development server - AMD ROCm GPU build"
"ai.noteflow.rocm.version" = ROCM_VERSION
}
}
# =============================================================================
# CI/CD Targets (GHA caching)
# =============================================================================
target "server-ci" {
inherits = ["server"]
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}
target "server-gpu-ci" {
inherits = ["server-gpu"]
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}
target "server-rocm-ci" {
inherits = ["server-rocm"]
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}