feat(agents): multi-arch checker and status page images on scratch
ci / image (pull_request) Successful in 7m15s
ci / test (pull_request) Successful in 9m5s
ci / lint (pull_request) Successful in 14m17s
ci / build (pull_request) Successful in 15m59s

uptimesebi-checker and uptimesebi-statuspage for linux/amd64, arm64,
arm/v7 and arm/v6, from a Raspberry Pi Zero to servers. tools/image
assembles them from the cross-compiled binaries without Docker or
emulation: one layer on an empty base with the binary, a data volume
owned by the unprivileged user and a HEALTHCHECK running the new
`checker health` / `statuspage health` commands. The binaries embed time
zone data and fallback CA roots, so no base image ever needs updating.
CI pushes them with the same channel tags as the main image; releases
carry tarballs for all four platforms.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-23 18:33:42 +01:00
1 parent e17e7aab41
commit a9f94fc492
12 files changed
+638 -9

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
// Command image builds the multi-arch images of an agent (checker or status
// page server) from cross-compiled binaries, without Docker: one layer on
// an empty base per platform, combined into an OCI index.
//
// image -name checker -dist dist -repo registry/owner/uptimesebi-checker \
// -version v1.2.3 -commit abc123 -ref refs/tags/v1.2.3 [-push]
//
// dist holds one directory per platform: linux_amd64, linux_arm64,
// linux_arm_v7 and linux_arm_v6, each with the binary. Without -push the
// index is only built and checked. The registry login comes from
// REGISTRY_USER and REGISTRY_PASSWORD.
package main
import (
"context"
"errors"
"flag"
"fmt"
"os"
"strings"
"time"
)
func main() {
if err := run(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
type listFlag []string
func (l *listFlag) String() string { return strings.Join(*l, ",") }
func (l *listFlag) Set(v string) error { *l = append(*l, v); return nil }
func run(args []string) error {
fs := flag.NewFlagSet("image", flag.ContinueOnError)
var o options
fs.StringVar(&o.Name, "name", "", "binary name: checker or statuspage")
fs.StringVar(&o.Dist, "dist", "dist", "directory with one subdirectory per platform")
fs.StringVar(&o.Repo, "repo", "", "image repository, e.g. git.example.com/owner/uptimesebi-checker")
fs.StringVar(&o.Version, "version", "dev", "release version")
fs.StringVar(&o.Commit, "commit", "", "git revision")
fs.StringVar(&o.Source, "source", "", "repository URL for the image labels")
fs.StringVar(&o.Suffix, "suffix", "", "tag suffix of an image variant, e.g. autoupdate")
fs.Var((*listFlag)(&o.Env), "env", "NAME=value baked into the image (repeatable)")
fs.Var((*listFlag)(&o.Ports), "port", "exposed port, e.g. 8081/tcp (repeatable)")
ref := fs.String("ref", "", "git ref being built, e.g. refs/heads/main or refs/tags/v1.2.3")
created := fs.Int64("created", 0, "creation time as Unix seconds, for reproducible images")
push := fs.Bool("push", false, "push to the registry")
insecure := fs.Bool("insecure", false, "talk plain HTTP to the registry")
if err := fs.Parse(args); err != nil {
return err
}
if o.Name == "" || o.Repo == "" {
return errors.New("image: -name and -repo are required")
}
o.Created = time.Unix(*created, 0).UTC()
idx, err := build(o)
if err != nil {
return err
}
digest, err := idx.Digest()
if err != nil {
return err
}
tags := channelTags(*ref, o.Version, o.Commit, o.Created, o.Suffix)
fmt.Printf("built %s@%s for %s\n", o.Repo, digest, strings.Join(platformNames(), ", "))
if !*push {
return nil
}
if len(tags) == 0 {
return fmt.Errorf("image: %q is not a ref that publishes images", *ref)
}
if *ref == "refs/heads/main" && (o.Commit == "" || *created == 0) {
return errors.New("image: builds of main need -commit and -created for their tag")
}
login := credentials{os.Getenv("REGISTRY_USER"), os.Getenv("REGISTRY_PASSWORD")}
if err := publish(context.Background(), idx, o.Repo, tags, login, *insecure); err != nil {
return err
}
fmt.Printf("pushed %s:%s\n", o.Repo, strings.Join(tags, ", :"))
return nil
}