From 10a5d998e6d7c0a7d3b7f3830f68c906903600ac Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Wed, 23 Nov 2022 22:35:12 +0100 Subject: [PATCH] useDockerDefaultOrServicePlatform fct should return service.platform if defined and present in the build.platforms list (or if the list is empty) Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- pkg/compose/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compose/build.go b/pkg/compose/build.go index 027a3dd01..fa7a3f5ef 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -415,8 +415,8 @@ func useDockerDefaultOrServicePlatform(project *types.Project, service types.Ser return plats, err } - if service.Platform != "" && !utils.StringContains(service.Build.Platforms, service.Platform) { - if len(service.Build.Platforms) > 0 { + if service.Platform != "" { + if len(service.Build.Platforms) > 0 && !utils.StringContains(service.Build.Platforms, service.Platform) { return nil, fmt.Errorf("service.platform %q should be part of the service.build.platforms: %q", service.Platform, service.Build.Platforms) } // User defined a service platform and no build platforms, so we should keep the one define on the service level