Skip to content

Commit c882ac2

Browse files
authored
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.
1 parent e56794d commit c882ac2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@ object DockerPlugin extends AutoPlugin {
300300
"--push"
301301
) ++ dockerBuildOptions.value :+ "."
302302
else dockerExecCommand.value
303-
alias.foreach { aliasValue =>
304-
publishDocker(context, execCommand, aliasValue.toString, log, multiplatform)
305-
}
303+
// For multiplatform builds, the alias are part of the `dockerBuildOptions` already.
304+
if (multiplatform) publishDocker(context, execCommand, dockerAlias.value.tag.getOrElse(""), log, multiplatform)
305+
else
306+
alias.foreach { aliasValue =>
307+
publishDocker(context, execCommand, aliasValue.toString, log, multiplatform)
308+
}
306309
} tag (Tags.Network, Tags.Publish)
307310

308311
def cleanTask =

0 commit comments

Comments
 (0)