Skip to content

Commit c20a50c

Browse files
committed
fix exporter to only load image for default platform
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 34a6f5b commit c20a50c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pkg/compose/build_bake.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
166166
privileged = true
167167
}
168168

169-
outputs := []string{"type=docker"}
170-
if options.Push && service.Image != "" {
171-
outputs = append(outputs, "type=image,push=true")
169+
var output string
170+
push := options.Push && service.Image != ""
171+
if len(service.Build.Platforms) > 1 {
172+
output = fmt.Sprintf("type=image,push=%t", push)
173+
} else {
174+
output = fmt.Sprintf("type=docker,load=true,push=%t", push)
172175
}
176+
173177
read = append(read, build.Context)
174178
for _, path := range build.AdditionalContexts {
175179
_, err := gitutil.ParseGitRef(path)
@@ -198,7 +202,7 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
198202
ShmSize: build.ShmSize,
199203
Ulimits: toBakeUlimits(build.Ulimits),
200204
Entitlements: entitlements,
201-
Outputs: outputs,
205+
Outputs: []string{output},
202206
}
203207
group.Targets = append(group.Targets, serviceName)
204208
}

pkg/e2e/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func TestBuildPlatformsWithCorrectBuildxConfig(t *testing.T) {
305305
"-f", "fixtures/build-test/platforms/compose-unsupported-platform.yml", "build")
306306
res.Assert(t, icmd.Expected{
307307
ExitCode: 1,
308-
Err: "no match for platform in",
308+
Err: "no match for platform",
309309
})
310310
})
311311

0 commit comments

Comments
 (0)