From c882ac2e75ce5d25f3ed7ef8c8cc2b29ae1a7b51 Mon Sep 17 00:00:00 2001 From: Darren Gibson Date: Mon, 25 Nov 2024 03:00:27 -0600 Subject: [PATCH] Fix multi-platform builds with multiple aliases. (#1651) Multi-platform builds append a `-t` argument for each alias to the `dockerBuildOptions`, but the `publishTask` function was ALWAYS iterating over the aliases even if it was a multi-platform build. The consequence was attempts to buildx and push the tags multiple times. In some environments this leads to build failures because you can't push the same tag twice. This change simply does not iterate over the aliases for multiplatform builds. --- .../com/typesafe/sbt/packager/docker/DockerPlugin.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala index 7175085bd..1ea423fd0 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala @@ -300,9 +300,12 @@ object DockerPlugin extends AutoPlugin { "--push" ) ++ dockerBuildOptions.value :+ "." else dockerExecCommand.value - alias.foreach { aliasValue => - publishDocker(context, execCommand, aliasValue.toString, log, multiplatform) - } + // For multiplatform builds, the alias are part of the `dockerBuildOptions` already. + if (multiplatform) publishDocker(context, execCommand, dockerAlias.value.tag.getOrElse(""), log, multiplatform) + else + alias.foreach { aliasValue => + publishDocker(context, execCommand, aliasValue.toString, log, multiplatform) + } } tag (Tags.Network, Tags.Publish) def cleanTask =