Files
noteflow/docker-bake.hcl

345 lines
9.4 KiB
HCL

# docker-bake.hcl
# Docker Buildx Bake configuration for NoteFlow
#
# Usage:
# docker buildx bake # Build default targets
# docker buildx bake server # Build CPU server only
# docker buildx bake server-gpu # Build GPU server only
# docker buildx bake server-rocm # Build ROCm GPU server only
# docker buildx bake servers # Build all server variants (parallel)
# docker buildx bake servers-gpu # Build GPU variants only (CUDA + ROCm)
# docker buildx bake client # Build client targets
# docker buildx bake all # Build everything
# docker buildx bake --print # Show build plan without building
#
# With specific options:
# docker buildx bake server --set server.tags=myregistry/noteflow:v1.0
# docker buildx bake --push all # Build and push all images
# =============================================================================
# Variables
# =============================================================================
variable "REGISTRY" {
default = ""
}
variable "IMAGE_PREFIX" {
default = "noteflow"
}
variable "TAG" {
default = "latest"
}
variable "PYTHON_VERSION" {
default = "3.12"
}
variable "CUDA_VERSION" {
default = "12.4.1"
}
variable "ROCM_VERSION" {
default = "7.1.1"
}
variable "ROCM_PYTORCH_RELEASE" {
default = "2.9.1"
}
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
# =============================================================================
function "tag" {
params = [name]
result = REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-${name}:${TAG}" : "${IMAGE_PREFIX}-${name}:${TAG}"
}
function "tags" {
params = [name]
result = [
tag(name),
REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-${name}:latest" : "${IMAGE_PREFIX}-${name}:latest"
]
}
# =============================================================================
# Groups - Enable parallel builds
# =============================================================================
group "default" {
targets = ["server"]
}
group "servers" {
targets = ["server", "server-gpu", "server-rocm"]
}
group "servers-gpu" {
targets = ["server-gpu", "server-rocm"]
}
group "servers-full" {
targets = ["server", "server-full", "server-gpu", "server-gpu-full", "server-rocm", "server-rocm-full"]
}
group "client" {
targets = ["client-build", "client-dev"]
}
group "all" {
targets = [
"server",
"server-full",
"server-gpu",
"server-gpu-full",
"server-rocm",
"server-rocm-full",
"client-build"
]
}
group "ci" {
targets = ["server", "server-gpu", "server-rocm", "client-build"]
}
# =============================================================================
# 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=${REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-server:cache" : "${IMAGE_PREFIX}-server: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=${REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-server-gpu:cache" : "${IMAGE_PREFIX}-server-gpu:cache"}"
]
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=${REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-server-rocm:cache" : "${IMAGE_PREFIX}-server-rocm:cache"}"
]
cache-to = [
"type=inline"
]
}
target "_client-common" {
inherits = ["_common"]
dockerfile = "docker/client.Dockerfile"
cache-from = [
"type=registry,ref=${REGISTRY != "" ? "${REGISTRY}/${IMAGE_PREFIX}-client:cache" : "${IMAGE_PREFIX}-client:cache"}"
]
cache-to = [
"type=inline"
]
}
# =============================================================================
# Server Targets (CPU)
# =============================================================================
target "server" {
inherits = ["_server-common"]
target = "server"
tags = tags("server")
labels = {
"org.opencontainers.image.title" = "NoteFlow Server (CPU)"
"org.opencontainers.image.description" = "NoteFlow gRPC server - CPU-only build"
}
}
target "server-full" {
inherits = ["_server-common"]
target = "server-full"
tags = tags("server-full")
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Full (CPU)"
"org.opencontainers.image.description" = "NoteFlow gRPC server with all extras - CPU-only build"
}
}
target "server-dev" {
inherits = ["_server-common"]
target = "dev"
tags = tags("server-dev")
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Dev (CPU)"
"org.opencontainers.image.description" = "NoteFlow development server - CPU-only build"
}
}
target "server-ner" {
inherits = ["_server-common"]
target = "with-ner"
tags = tags("server-ner")
labels = {
"org.opencontainers.image.title" = "NoteFlow Server with NER (CPU)"
"org.opencontainers.image.description" = "NoteFlow server with spaCy NER - CPU-only build"
}
}
# =============================================================================
# Server Targets (GPU - NVIDIA CUDA)
# =============================================================================
target "server-gpu" {
inherits = ["_server-gpu-common"]
target = "server"
tags = tags("server-gpu")
platforms = ["linux/amd64"] # GPU images are x86_64 only
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
}
}
target "server-gpu-full" {
inherits = ["_server-gpu-common"]
target = "server-full"
tags = tags("server-gpu-full")
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Full (GPU)"
"org.opencontainers.image.description" = "NoteFlow gRPC server with all extras - NVIDIA CUDA GPU build"
"ai.noteflow.cuda.version" = CUDA_VERSION
}
}
# =============================================================================
# Server Targets (GPU - AMD ROCm)
# =============================================================================
target "server-rocm" {
inherits = ["_server-rocm-common"]
target = "server"
tags = tags("server-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
}
}
target "server-rocm-full" {
inherits = ["_server-rocm-common"]
target = "server-full"
tags = tags("server-rocm-full")
platforms = ["linux/amd64"]
labels = {
"org.opencontainers.image.title" = "NoteFlow Server Full (ROCm)"
"org.opencontainers.image.description" = "NoteFlow gRPC server with all extras - AMD ROCm GPU build"
"ai.noteflow.rocm.version" = ROCM_VERSION
}
}
# =============================================================================
# Client Targets
# =============================================================================
target "client-build" {
inherits = ["_client-common"]
target = "client-build"
tags = tags("client")
labels = {
"org.opencontainers.image.title" = "NoteFlow Client Build"
"org.opencontainers.image.description" = "NoteFlow Tauri desktop client build"
}
}
target "client-dev" {
inherits = ["_client-common"]
target = "client-dev"
tags = tags("client-dev")
labels = {
"org.opencontainers.image.title" = "NoteFlow Client Dev"
"org.opencontainers.image.description" = "NoteFlow Tauri client development environment"
}
}
# =============================================================================
# Multi-Platform Targets (for CPU images)
# =============================================================================
target "server-multiplatform" {
inherits = ["server"]
platforms = ["linux/amd64", "linux/arm64"]
tags = tags("server-multiplatform")
}
target "server-full-multiplatform" {
inherits = ["server-full"]
platforms = ["linux/amd64", "linux/arm64"]
tags = tags("server-full-multiplatform")
}
# =============================================================================
# CI/CD Specific Targets
# =============================================================================
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"
]
}