feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Package builders provides build implementations for different project types.
|
|
|
|
|
package builders
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-04-01 13:24:35 +00:00
|
|
|
"runtime"
|
2026-04-01 12:40:30 +00:00
|
|
|
"strings"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
"dappco.re/go/core"
|
|
|
|
|
"dappco.re/go/core/build/internal/ax"
|
2026-03-22 01:53:16 +00:00
|
|
|
"dappco.re/go/core/build/pkg/build"
|
|
|
|
|
"dappco.re/go/core/io"
|
|
|
|
|
coreerr "dappco.re/go/core/log"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// DockerBuilder builds Docker images.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// b := builders.NewDockerBuilder()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
type DockerBuilder struct{}
|
|
|
|
|
|
|
|
|
|
// NewDockerBuilder creates a new Docker builder.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// b := builders.NewDockerBuilder()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func NewDockerBuilder() *DockerBuilder {
|
|
|
|
|
return &DockerBuilder{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Name returns the builder's identifier.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// name := b.Name() // → "docker"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (b *DockerBuilder) Name() string {
|
|
|
|
|
return "docker"
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:11:37 +00:00
|
|
|
// Detect checks if a Dockerfile or Containerfile exists in the directory.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// ok, err := b.Detect(io.Local, ".")
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (b *DockerBuilder) Detect(fs io.Medium, dir string) (bool, error) {
|
2026-04-02 00:11:37 +00:00
|
|
|
if build.ResolveDockerfilePath(fs, dir) != "" {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
return false, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build builds Docker images for the specified targets.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// artifacts, err := b.Build(ctx, cfg, []build.Target{{OS: "linux", Arch: "amd64"}})
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (b *DockerBuilder) Build(ctx context.Context, cfg *build.Config, targets []build.Target) ([]build.Artifact, error) {
|
2026-03-30 01:19:19 +00:00
|
|
|
dockerCommand, err := b.resolveDockerCli()
|
|
|
|
|
if err != nil {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure buildx is available
|
2026-03-30 01:19:19 +00:00
|
|
|
if err := b.ensureBuildx(ctx, dockerCommand); err != nil {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:11:37 +00:00
|
|
|
// Determine Docker manifest path
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
dockerfile := cfg.Dockerfile
|
|
|
|
|
if dockerfile == "" {
|
2026-04-02 00:11:37 +00:00
|
|
|
dockerfile = build.ResolveDockerfilePath(cfg.FS, cfg.ProjectDir)
|
2026-04-02 02:30:31 +00:00
|
|
|
} else if !ax.IsAbs(dockerfile) {
|
|
|
|
|
dockerfile = ax.Join(cfg.ProjectDir, dockerfile)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate Dockerfile exists
|
2026-04-02 00:11:37 +00:00
|
|
|
if dockerfile == "" || !cfg.FS.IsFile(dockerfile) {
|
|
|
|
|
return nil, coreerr.E("DockerBuilder.Build", "Dockerfile or Containerfile not found", nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine image name
|
|
|
|
|
imageName := cfg.Image
|
|
|
|
|
if imageName == "" {
|
|
|
|
|
imageName = cfg.Name
|
|
|
|
|
}
|
|
|
|
|
if imageName == "" {
|
2026-03-26 17:41:53 +00:00
|
|
|
imageName = ax.Base(cfg.ProjectDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build platform string from targets
|
2026-04-01 12:40:30 +00:00
|
|
|
buildTargets := targets
|
|
|
|
|
if len(buildTargets) == 0 {
|
2026-04-01 13:24:35 +00:00
|
|
|
buildTargets = []build.Target{{OS: runtime.GOOS, Arch: runtime.GOARCH}}
|
2026-04-01 12:40:30 +00:00
|
|
|
}
|
2026-04-01 13:24:35 +00:00
|
|
|
|
|
|
|
|
var platforms []string
|
|
|
|
|
for _, t := range buildTargets {
|
|
|
|
|
platforms = append(platforms, core.Sprintf("%s/%s", t.OS, t.Arch))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine registry
|
|
|
|
|
registry := cfg.Registry
|
|
|
|
|
if registry == "" {
|
|
|
|
|
registry = "ghcr.io"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine tags
|
|
|
|
|
tags := cfg.Tags
|
|
|
|
|
if len(tags) == 0 {
|
|
|
|
|
tags = []string{"latest"}
|
|
|
|
|
if cfg.Version != "" {
|
|
|
|
|
tags = append(tags, cfg.Version)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build full image references
|
|
|
|
|
var imageRefs []string
|
|
|
|
|
for _, tag := range tags {
|
|
|
|
|
// Expand version template
|
2026-03-26 17:41:53 +00:00
|
|
|
expandedTag := core.Replace(tag, "{{.Version}}", cfg.Version)
|
|
|
|
|
expandedTag = core.Replace(expandedTag, "{{Version}}", cfg.Version)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
if registry != "" {
|
2026-03-26 17:41:53 +00:00
|
|
|
imageRefs = append(imageRefs, core.Sprintf("%s/%s:%s", registry, imageName, expandedTag))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
} else {
|
2026-03-26 17:41:53 +00:00
|
|
|
imageRefs = append(imageRefs, core.Sprintf("%s:%s", imageName, expandedTag))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build the docker buildx command
|
|
|
|
|
args := []string{"buildx", "build"}
|
|
|
|
|
|
|
|
|
|
// Multi-platform support
|
2026-03-26 17:41:53 +00:00
|
|
|
args = append(args, "--platform", core.Join(",", platforms...))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
// Add all tags
|
|
|
|
|
for _, ref := range imageRefs {
|
|
|
|
|
args = append(args, "-t", ref)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Dockerfile path
|
|
|
|
|
args = append(args, "-f", dockerfile)
|
|
|
|
|
|
|
|
|
|
// Build arguments
|
|
|
|
|
for k, v := range cfg.BuildArgs {
|
2026-03-26 17:41:53 +00:00
|
|
|
expandedValue := core.Replace(v, "{{.Version}}", cfg.Version)
|
|
|
|
|
expandedValue = core.Replace(expandedValue, "{{Version}}", cfg.Version)
|
|
|
|
|
args = append(args, "--build-arg", core.Sprintf("%s=%s", k, expandedValue))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Always add VERSION build arg if version is set
|
|
|
|
|
if cfg.Version != "" {
|
2026-03-26 17:41:53 +00:00
|
|
|
args = append(args, "--build-arg", core.Sprintf("VERSION=%s", cfg.Version))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:40:30 +00:00
|
|
|
safeImageName := strings.ReplaceAll(imageName, "/", "_")
|
|
|
|
|
|
2026-04-01 15:24:33 +00:00
|
|
|
// Output to local docker images or push.
|
|
|
|
|
// `--load` only works for a single target, so multi-platform local builds
|
|
|
|
|
// fall back to an OCI archive on disk.
|
|
|
|
|
useLoad := cfg.Load && !cfg.Push && len(buildTargets) == 1
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if cfg.Push {
|
|
|
|
|
args = append(args, "--push")
|
2026-04-01 15:24:33 +00:00
|
|
|
} else if useLoad {
|
|
|
|
|
args = append(args, "--load")
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
} else {
|
2026-04-01 12:40:30 +00:00
|
|
|
// Local Docker builds emit an OCI archive so the build output is a file.
|
|
|
|
|
outputPath := ax.Join(cfg.OutputDir, core.Sprintf("%s.tar", safeImageName))
|
|
|
|
|
args = append(args, "--output", core.Sprintf("type=oci,dest=%s", outputPath))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build context (project directory)
|
|
|
|
|
args = append(args, cfg.ProjectDir)
|
|
|
|
|
|
|
|
|
|
// Create output directory
|
|
|
|
|
if err := cfg.FS.EnsureDir(cfg.OutputDir); err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return nil, coreerr.E("DockerBuilder.Build", "failed to create output directory", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
core.Print(nil, "Building Docker image: %s", imageName)
|
|
|
|
|
core.Print(nil, " Platforms: %s", core.Join(", ", platforms...))
|
|
|
|
|
core.Print(nil, " Tags: %s", core.Join(", ", imageRefs...))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
2026-04-01 12:40:30 +00:00
|
|
|
// Build once for the full platform set. Docker buildx produces a single
|
|
|
|
|
// multi-arch image or OCI archive from the combined platform list.
|
2026-04-01 16:02:09 +00:00
|
|
|
if err := ax.ExecWithEnv(ctx, cfg.ProjectDir, cfg.Env, dockerCommand, args...); err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return nil, coreerr.E("DockerBuilder.Build", "buildx build failed", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:40:30 +00:00
|
|
|
artifactPath := imageRefs[0]
|
2026-04-01 15:24:33 +00:00
|
|
|
if !cfg.Push && !useLoad {
|
2026-04-01 12:40:30 +00:00
|
|
|
artifactPath = ax.Join(cfg.OutputDir, core.Sprintf("%s.tar", safeImageName))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:40:30 +00:00
|
|
|
primaryTarget := buildTargets[0]
|
|
|
|
|
return []build.Artifact{{
|
|
|
|
|
Path: artifactPath,
|
|
|
|
|
OS: primaryTarget.OS,
|
|
|
|
|
Arch: primaryTarget.Arch,
|
|
|
|
|
}}, nil
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-30 01:19:19 +00:00
|
|
|
// resolveDockerCli returns the executable path for the docker CLI.
|
|
|
|
|
func (b *DockerBuilder) resolveDockerCli(paths ...string) (string, error) {
|
|
|
|
|
if len(paths) == 0 {
|
|
|
|
|
paths = []string{
|
|
|
|
|
"/usr/local/bin/docker",
|
|
|
|
|
"/opt/homebrew/bin/docker",
|
|
|
|
|
"/Applications/Docker.app/Contents/Resources/bin/docker",
|
|
|
|
|
}
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
2026-03-30 01:19:19 +00:00
|
|
|
|
|
|
|
|
command, err := ax.ResolveCommand("docker", paths...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", coreerr.E("DockerBuilder.resolveDockerCli", "docker CLI not found. Install it from https://docs.docker.com/get-docker/", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return command, nil
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ensureBuildx ensures docker buildx is available and has a builder.
|
2026-03-30 01:19:19 +00:00
|
|
|
func (b *DockerBuilder) ensureBuildx(ctx context.Context, dockerCommand string) error {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Check if buildx is available
|
2026-03-30 01:19:19 +00:00
|
|
|
if err := ax.Exec(ctx, dockerCommand, "buildx", "version"); err != nil {
|
2026-03-17 13:46:48 +00:00
|
|
|
return coreerr.E("DockerBuilder.ensureBuildx", "buildx is not available. Install it from https://docs.docker.com/buildx/working-with-buildx/", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if we have a builder, create one if not
|
2026-03-30 01:19:19 +00:00
|
|
|
if err := ax.Exec(ctx, dockerCommand, "buildx", "inspect", "--bootstrap"); err != nil {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Try to create a builder
|
2026-03-30 01:19:19 +00:00
|
|
|
if err := ax.Exec(ctx, dockerCommand, "buildx", "create", "--use", "--bootstrap"); err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("DockerBuilder.ensureBuildx", "failed to create buildx builder", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|