Skip to content

Commit

Permalink
Reformat with scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Ofenbeck - taaofge1 committed May 4, 2024
1 parent ca6388f commit 6956a1a
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions contrib/docker/src/mill/contrib/docker/DockerModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ trait DockerModule { outer: JavaModule =>
def user: T[String] = ""

/**
* Optional platform parameter, if set uses buildkit to build for specified platform.
*
* See also the Docker docs on
* [[https://docs.docker.com/reference/cli/docker/buildx/build/#platform]]
* for more information.
*/
* Optional platform parameter, if set uses buildkit to build for specified platform.
*
* See also the Docker docs on
* [[https://docs.docker.com/reference/cli/docker/buildx/build/#platform]]
* for more information.
*/
def platform: T[String] = ""

/**
Expand Down Expand Up @@ -164,14 +164,25 @@ trait DockerModule { outer: JavaModule =>
val (pull, _) = pullAndHash()
val pullLatestBase = IterableShellable(if (pull) Some("--pull") else None)


val result = if (platform().isEmpty || executable() != "docker") {
if (platform().nonEmpty) log.info("Platform parameter is ignored when using non-docker executable")
if (!platform().isEmpty)
log.warn(
"Building for other platforms is currently only supported through buildx on docker"
)
os.proc(executable(), "build", tagArgs, pullLatestBase, dest)
.call(stdout = os.Inherit, stderr = os.Inherit)
.call(stdout = os.Inherit, stderr = os.Inherit)
} else {
os.proc(executable(),"buildx", "build", tagArgs, pullLatestBase, "--platform", platform(), dest)
.call(stdout = os.Inherit, stderr = os.Inherit)
os.proc(
executable(),
"buildx",
"build",
tagArgs,
pullLatestBase,
"--platform",
platform(),
dest
)
.call(stdout = os.Inherit, stderr = os.Inherit)
}
log.info(s"Docker build completed ${if (result.exitCode == 0) "successfully"
else "unsuccessfully"} with ${result.exitCode}")
Expand Down

0 comments on commit 6956a1a

Please # to comment.