feat: migrate builds plugin to go and track per-build records

Adds typed JSON build records under data/builds/<app>/<build-id>.{json,log} keyed on a stable base36 ULID-style DOKKU_BUILD_ID generated for every deploy. The new commands surface that history (builds:list, builds:info, builds:prune) and an operator-configurable retention via builds:set retention. The existing builds:cancel and builds:output now key on the build-id (with safe handling for already-finalized and abandoned records), and the per-build log file replaces journalctl as the durable source of truth for builds:output.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-04-30 01:18:03 -04:00
1 parent 3b3bc3dd39
commit 67e4cf04ab
30 files changed
+2690 -196

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
const (
helpHeader = `Usage: dokku builds[:COMMAND]
Manage running and historical builds
Additional commands:`
helpContent = `
builds:cancel <app>, Cancel a running build for an app
builds:info <app> <build-id> [--format json|stdout], Show details for a single build
builds:list [<app>] [--format json] [--kind build|deploy] [--status <status>], List builds
builds:output <app> [<build-id>|current], Show build output
builds:prune <app> [--all-apps], Prune build records to retention
builds:report [<app>] [<flag>], Display a build report for one or more apps
builds:set [--global|<app>] <key> [<value>], Set or clear a builds property`
)
func main() {
flag.Usage = usage
flag.Parse()
cmd := flag.Arg(0)
switch cmd {
case "builds", "builds:help":
usage()
case "help":
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "ps",
Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())},
})
if err == nil && strings.Contains(result.StdoutContents(), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n builds, Manage running and historical builds\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {
fmt.Println("failed to retrieve DOKKU_NOT_IMPLEMENTED_EXIT environment variable")
dokkuNotImplementExitCode = 10
}
os.Exit(dokkuNotImplementExitCode)
}
}
func usage() {
common.CommandUsage(helpHeader, helpContent)
}