Selaa lähdekoodia

force buildx on build (#4220)

Stefan McShane 2 vuotta sitten
vanhempi
sitoutus
c204d9755d
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      cli/cmd/docker/builder.go

+ 5 - 1
cli/cmd/docker/builder.go

@@ -12,6 +12,7 @@ import (
 	"os"
 	"os/exec"
 	"path/filepath"
+	"strings"
 	"time"
 
 	"github.com/docker/docker/api/types"
@@ -214,10 +215,11 @@ func buildLocalWithBuildkit(ctx context.Context, opts BuildOpts) error {
 	}
 
 	commandArgs := []string{
+		"buildx",
 		"build",
 		"-f", dockerfileName,
 		"--tag", fmt.Sprintf("%s:%s", opts.ImageRepo, opts.Tag),
-		"--cache-from", fmt.Sprintf("%s:%s", opts.ImageRepo, opts.CurrentTag),
+		"--cache-from", fmt.Sprintf("type=registry,ref=%s:%s", opts.ImageRepo, opts.CurrentTag),
 	}
 	for key, val := range opts.Env {
 		commandArgs = append(commandArgs, "--build-arg", fmt.Sprintf("%s=%s", key, val))
@@ -238,6 +240,8 @@ func buildLocalWithBuildkit(ctx context.Context, opts BuildOpts) error {
 		stderrWriters = append(stderrWriters, opts.LogFile)
 	}
 
+	fmt.Println("Running build command: docker", strings.Join(commandArgs, " "))
+
 	// #nosec G204 - The command is meant to be variable
 	cmd := exec.CommandContext(ctx, "docker", commandArgs...)
 	cmd.Dir = opts.BuildContext