From a6cc96fbda7820bd741a08badca978577c33857c Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 16 Jun 2021 22:21:00 +0200 Subject: [PATCH] fix: allow multi-platform builds using --push flag (#29) --- plugin/docker.go | 7 ++++++- plugin/impl.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/docker.go b/plugin/docker.go index d7900f4..8350d48 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -65,7 +65,6 @@ func commandBuild(build Build) *exec.Cmd { args := []string{ "buildx", "build", - "--load", "--rm=true", "-f", build.Dockerfile, "-t", build.Name, @@ -107,6 +106,12 @@ func commandBuild(build Build) *exec.Cmd { args = append(args, "--quiet") } + if len(build.Platforms.Value()) > 1 { + args = append(args, "--push") + } else { + args = append(args, "--load") + } + if len(build.Platforms.Value()) > 0 { args = append(args, "--platform", strings.Join(build.Platforms.Value()[:], ",")) } diff --git a/plugin/impl.go b/plugin/impl.go index e8c249e..6e0464e 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -83,6 +83,10 @@ func (p *Plugin) Validate() error { p.settings.Build.Ref = p.pipeline.Commit.Ref p.settings.Daemon.Registry = p.settings.Login.Registry + if len(p.settings.Build.Platforms.Value()) > 1 && p.settings.Dryrun { + return fmt.Errorf("dryrun is not supported on multi-platform builds") + } + if p.settings.Build.TagsAuto { // return true if tag event or default branch if UseDefaultTag(