From 6dbf8bb97d312b3bf21a6611fd37512ab3343c30 Mon Sep 17 00:00:00 2001 From: marko asplund Date: Sun, 17 Dec 2023 20:23:08 +0200 Subject: [PATCH] Change packaging and Docker deployment strategy Switch from sbt-assembly + sbt-docker to using sbt-native-packager The former approach builds a fat jar that results in class file deduplication issues described in: https://github.com/sbt/sbt-assembly/issues/391 sbt-native-packager does not rely in building a fat jar --- build.sbt | 26 +++++--------------------- project/plugins.sbt | 4 ++-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/build.sbt b/build.sbt index 529047e..d4f2006 100644 --- a/build.sbt +++ b/build.sbt @@ -35,25 +35,9 @@ libraryDependencies ++= { parallelExecution in Test := false +enablePlugins(JavaAppPackaging) enablePlugins(DockerPlugin) -assemblyJarName in assembly := "s3mock.jar" -mainClass in assembly := Some("io.findify.s3mock.Main") -test in assembly := {} - -dockerfile in docker := new Dockerfile { - from("adoptopenjdk/openjdk11:jre-11.0.7_10-debian") - expose(8001) - add(assembly.value, "/app/s3mock.jar") - entryPoint( - "java", - "-Xmx128m", - "-jar", - "--add-opens", - "java.base/jdk.internal.ref=ALL-UNNAMED", - "/app/s3mock.jar" - ) -} -imageNames in docker := Seq( - ImageName(s"findify/s3mock:${version.value.replaceAll("\\+", "_")}"), - ImageName(s"findify/s3mock:latest") -) + +dockerRepository := Some("io.github.marko-asplund") +dockerBaseImage := "eclipse-temurin:11-jre" +dockerExposedPorts := Seq(8001) diff --git a/project/plugins.sbt b/project/plugins.sbt index 776e44f..b2667bc 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,5 +5,5 @@ addDependencyTreePlugin addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0") addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.11.0") + +addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")