diff --git a/internal/openclaw/openclaw.go b/internal/openclaw/openclaw.go index aec66bee..8d1efc68 100644 --- a/internal/openclaw/openclaw.go +++ b/internal/openclaw/openclaw.go @@ -75,6 +75,15 @@ func openclawImageTag() string { return "" } +// ImageRef returns the pinned OpenClaw image reference used by the local +// binary when it writes overlay values. Empty string means no explicit ref. +func ImageRef() string { + if tag := openclawImageTag(); tag != "" { + return "ghcr.io/obolnetwork/openclaw:" + tag + } + return "" +} + // OnboardOptions contains options for the onboard command type OnboardOptions struct { ID string // Deployment ID (empty = generate petname) diff --git a/internal/stack/stack.go b/internal/stack/stack.go index 7ea80f2e..5ed61cd5 100644 --- a/internal/stack/stack.go +++ b/internal/stack/stack.go @@ -691,6 +691,14 @@ var localImages = []localImage{ {tag: "ghcr.io/obolnetwork/x402-buyer:latest", dockerfile: "Dockerfile.x402-buyer"}, } +func devPreloadImages() []string { + var images []string + if ref := openclaw.ImageRef(); ref != "" { + images = append(images, ref) + } + return images +} + // buildAndImportLocalImages builds Docker images from source and imports them // into the k3d cluster. This ensures images are available even when the GHCR // publish workflow hasn't run. Non-fatal: logs warnings on failure. @@ -736,6 +744,20 @@ func buildAndImportLocalImages(cfg *config.Config) { fmt.Printf("Warning: failed to import %s into k3d: %v\n", img.tag, err) } } + + for _, ref := range devPreloadImages() { + fmt.Printf("Preloading %s into cluster %s...\n", ref, clusterName) + pullCmd := exec.Command("docker", "pull", ref) + pullCmd.Stdout = os.Stdout + pullCmd.Stderr = os.Stderr + if err := pullCmd.Run(); err != nil { + fmt.Printf("Warning: failed to pull %s: %v\n", ref, err) + continue + } + if err := importImageToCluster(k3dBinary, clusterName, ref); err != nil { + fmt.Printf("Warning: failed to import %s into k3d: %v\n", ref, err) + } + } } func importImageToCluster(k3dBinary, clusterName, tag string) error {