# docker-bake.hcl — defines all five production images. # # CI passes version info as environment variables; locally everything gets :dev tags. # # Local build (no push): # docker buildx bake # # CI environment variables: VERSION, MAJOR_MINOR, COMMIT, BUILD_TIME variable "DOCKER_USER" { default = "kalekber" } variable "VERSION" { default = "dev" } # e.g. "4.1.6" (no leading v) variable "MAJOR_MINOR" { default = "dev" } # e.g. "4.1" variable "COMMIT" { default = "unknown" } variable "BUILD_TIME" { default = "" } # ── Shared defaults ─────────────────────────────────────────────────────────── target "_defaults" { pull = true # CI overrides to push=true via --set *.output=type=image,push=true output = ["type=image,push=false"] cache-to = ["type=inline"] } # ── Go targets (share the backend/ build context + builder stage) ───────────── target "backend" { inherits = ["_defaults"] context = "backend" target = "backend" tags = [ "${DOCKER_USER}/libnovel-backend:${VERSION}", "${DOCKER_USER}/libnovel-backend:${MAJOR_MINOR}", "${DOCKER_USER}/libnovel-backend:latest", ] cache-from = ["type=registry,ref=${DOCKER_USER}/libnovel-backend:latest"] args = { VERSION = VERSION COMMIT = COMMIT } } target "runner" { inherits = ["_defaults"] context = "backend" target = "runner" tags = [ "${DOCKER_USER}/libnovel-runner:${VERSION}", "${DOCKER_USER}/libnovel-runner:${MAJOR_MINOR}", "${DOCKER_USER}/libnovel-runner:latest", ] cache-from = ["type=registry,ref=${DOCKER_USER}/libnovel-runner:latest"] args = { VERSION = VERSION COMMIT = COMMIT } } target "pocketbase" { inherits = ["_defaults"] context = "backend" target = "pocketbase" tags = [ "${DOCKER_USER}/libnovel-pocketbase:${VERSION}", "${DOCKER_USER}/libnovel-pocketbase:${MAJOR_MINOR}", "${DOCKER_USER}/libnovel-pocketbase:latest", ] cache-from = ["type=registry,ref=${DOCKER_USER}/libnovel-pocketbase:latest"] } # ── UI (SvelteKit — separate context) ──────────────────────────────────────── target "ui" { inherits = ["_defaults"] context = "ui" tags = [ "${DOCKER_USER}/libnovel-ui:${VERSION}", "${DOCKER_USER}/libnovel-ui:${MAJOR_MINOR}", "${DOCKER_USER}/libnovel-ui:latest", ] cache-from = ["type=registry,ref=${DOCKER_USER}/libnovel-ui:latest"] args = { BUILD_VERSION = VERSION BUILD_COMMIT = COMMIT BUILD_TIME = BUILD_TIME } } # ── Caddy (custom plugins — separate context) ───────────────────────────────── target "caddy" { inherits = ["_defaults"] context = "caddy" tags = [ "${DOCKER_USER}/libnovel-caddy:${VERSION}", "${DOCKER_USER}/libnovel-caddy:${MAJOR_MINOR}", "${DOCKER_USER}/libnovel-caddy:latest", ] cache-from = ["type=registry,ref=${DOCKER_USER}/libnovel-caddy:latest"] } # ── Default group: all five images ──────────────────────────────────────────── group "default" { targets = ["backend", "runner", "pocketbase", "ui", "caddy"] }