Skip to content

Commit eafe915

Browse files
committed
cmd/rofl/build: Pull builder Docker image at start and show progress
1 parent 888f4af commit eafe915

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cmd/rofl/build/build.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"maps"
88
"os"
9+
"os/exec"
910
"slices"
1011

1112
"github.com/spf13/cobra"
@@ -68,6 +69,7 @@ var (
6869
fmt.Printf("Version: %s\n", manifest.Version)
6970
fmt.Printf("TEE: %s\n", manifest.TEE)
7071
fmt.Printf("Kind: %s\n", manifest.Kind)
72+
fmt.Println()
7173

7274
switch deployment.Debug {
7375
case true:
@@ -104,6 +106,24 @@ var (
104106
)
105107
containerEnv.AddDirectory(tmpDir)
106108
buildEnv = containerEnv
109+
110+
if buildEnv.IsAvailable() {
111+
fmt.Printf("Initializing build environment...\n")
112+
// Run a dummy command to make sure that all necessary Docker layers
113+
// for the build environment are downloaded at the start instead of
114+
// later in the build process.
115+
// Also pipe all output from the process to stdout/stderr, so the user
116+
// can follow the progress in real-time.
117+
cmd := exec.Command("true")
118+
cmd.Stdout = os.Stdout
119+
cmd.Stderr = os.Stderr
120+
if err = buildEnv.WrapCommand(cmd); err != nil {
121+
return fmt.Errorf("unable to wrap command: %w", err)
122+
}
123+
if err = cmd.Run(); err != nil {
124+
return fmt.Errorf("failed to initialize build environment: %w", err)
125+
}
126+
}
107127
}
108128

109129
if !buildEnv.IsAvailable() {

0 commit comments

Comments
 (0)