scala-steward icon indicating copy to clipboard operation
scala-steward copied to clipboard

Publish Multi-Architecture Docker images

Open bpholt opened this issue 3 years ago • 5 comments

I have trouble running the official fthomas/scala-steward:0.14.0 Docker image on the Apple M1-based Mac I've been issued at work. Building an image locally works, but requires the modification of some of the build steps, in addition to using a different base image.

In theory, this project should be able to publish a multi-architecture Docker image, such that users running on different platforms (x86-64, ARM64, etc) would be able to run an image native to their platform.

Is that something this project would be interested in doing, if it required changing from adoptopenjdk/openjdk11:alpine to the non-Alpine variant of Eclipse Temurin? (The Alpine-based Temurin images currently only support AMD64, not ARM64.)

If so, I will try to put together a PR proposing how it could be done, but I thought I'd ask before spending too much time on it.

bpholt avatar Apr 27 '22 23:04 bpholt

Posting my diff of what I used to build for arm architecture.

@@ -301,11 +301,11 @@ lazy val metadataSettings = Def.settings(
   )
 )
 
 lazy val dockerSettings = Def.settings(
   dockerBaseImage := Option(System.getenv("DOCKER_BASE_IMAGE"))
-    .getOrElse("adoptopenjdk/openjdk11:alpine"),
+    .getOrElse("eclipse-temurin:11"),
   dockerCommands ++= {
     val binDir = "/usr/local/bin"
     val sbtVer = sbtVersion.value
     val sbtTgz = s"sbt-$sbtVer.tgz"
     val sbtUrl = s"https://github.com/sbt/sbt/releases/download/v$sbtVer/$sbtTgz"
@@ -314,11 +314,12 @@ lazy val dockerSettings = Def.settings(
     val millUrl =
       s"https://github.com/lihaoyi/mill/releases/download/${millVer.split("-").head}/$millVer"
     val coursierBin = s"$binDir/coursier"
     Seq(
       Cmd("USER", "root"),
-      Cmd("RUN", "apk --no-cache add bash git ca-certificates curl maven openssh"),
+      Cmd("RUN", "apt-get -y update"),
+      Cmd("RUN", "apt-get -y install maven wget curl bash git ca-certificates openssh-client"),
       Cmd("RUN", s"wget $sbtUrl && tar -xf $sbtTgz && rm -f $sbtTgz"),
       Cmd("RUN", s"curl -L $millUrl > $millBin && chmod +x $millBin"),
       Cmd("RUN", s"curl -L https://git.io/coursier-cli > $coursierBin && chmod +x $coursierBin"),
       Cmd("RUN", s"$coursierBin install --install-dir $binDir scalafix scalafmt")
     )

Need to compose multiple runs in a single one and add cache cleanup to reduce layer size.

arixmkii avatar Jun 17 '22 14:06 arixmkii

I don't use the Scala Steward Docker image and I'm also not very familiar with the Docker ecosystem. I'll probably merge anything Docker related if it sounds reasonable to me. :-)

fthomas avatar Jun 21 '22 16:06 fthomas