Skip to content

Commit

Permalink
Build various JVM docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
peel committed Oct 3, 2023
1 parent 2e644b3 commit 909eaae
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 33 deletions.
108 changes: 76 additions & 32 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ lazy val allSettings = buildSettings ++
lazy val root = project
.in(file("."))
.settings(buildSettings ++ dynVerSettings)
.aggregate(core, kinesis, pubsub, kafka, nsq, stdout, sqs, rabbitmq, http4s)
.aggregate(
core,
kinesis,
kafka,
nsq,
stdout,
sqs,
rabbitmq,
http4s,
pubsub
)

lazy val core = project
.settings(moduleName := "snowplow-stream-collector-core")
Expand Down Expand Up @@ -144,12 +154,10 @@ lazy val http4s = project
Dependencies.Libraries.circeConfig,
Dependencies.Libraries.specs2,
Dependencies.Libraries.specs2CE,

//Integration tests
Dependencies.Libraries.IT.testcontainers,
Dependencies.Libraries.IT.http4sClient,
Dependencies.Libraries.IT.catsRetry

)
)
.settings(Defaults.itSettings)
Expand All @@ -167,23 +175,23 @@ lazy val kinesisSettings =
Dependencies.Libraries.sqs,
// integration tests dependencies
Dependencies.Libraries.IT.specs2,
Dependencies.Libraries.IT.specs2CE,
Dependencies.Libraries.IT.specs2CE
),
IntegrationTest / test := (IntegrationTest / test).dependsOn(Docker / publishLocal).value,
IntegrationTest / test := (IntegrationTest / test).dependsOn(Docker / publishLocal).value,
IntegrationTest / testOnly := (IntegrationTest / testOnly).dependsOn(Docker / publishLocal).evaluated
)

lazy val kinesis = project
.settings(kinesisSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile;it->it")
.configs(IntegrationTest)

lazy val kinesisDistroless = project
.in(file("distroless/kinesis"))
.settings(sourceDirectory := (kinesis / sourceDirectory).value)
.settings(kinesisSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile;it->it")
.configs(IntegrationTest)

Expand All @@ -195,51 +203,87 @@ lazy val sqsSettings =
libraryDependencies ++= Seq(
Dependencies.Libraries.catsRetry,
Dependencies.Libraries.sqs,
Dependencies.Libraries.sts,
Dependencies.Libraries.sts
)
)

lazy val sqs = project
.settings(sqsSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile")

lazy val sqsDistroless = project
.in(file("distroless/sqs"))
.settings(sourceDirectory := (sqs / sourceDirectory).value)
.settings(sqsSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile")

lazy val pubsubSettings =
allSettings ++ buildInfoSettings ++ http4sBuildInfoSettings ++ Defaults.itSettings ++ scalifiedSettings ++ Seq(
moduleName := "snowplow-stream-collector-google-pubsub",
buildInfoPackage := s"com.snowplowanalytics.snowplow.collectors.scalastream",
dockerPermissionStrategy := DockerPermissionStrategy.CopyChown,
dockerRepository := Some("peelsky"),
Docker / packageName := "scala-stream-collector-pubsub",
Docker / daemonUserUid := None,
Docker / daemonGroup := "nonroot",
Docker / daemonUser := "nonroot",
Docker / maintainer := "Snowplow Analytics Ltd. <[email protected]>",
dockerBuildxPlatforms := Seq("linux/arm64", "linux/amd64"),
dockerBuildCommand := dockerExecCommand.value ++ {
if (dockerBuildxPlatforms.value.isEmpty) Seq("build")
else
Seq("buildx", "build", "--push", s"""--platform=${dockerBuildxPlatforms.value.mkString(",")}""") ++ dockerBuildOptions.value :+ "."
},
defaultLinuxInstallLocation := "/opt/snowplow",
libraryDependencies ++= Seq(
Dependencies.Libraries.catsRetry,
Dependencies.Libraries.fs2PubSub,
// integration tests dependencies
Dependencies.Libraries.IT.specs2,
Dependencies.Libraries.IT.specs2CE,
Dependencies.Libraries.IT.specs2,
Dependencies.Libraries.IT.specs2CE
),
IntegrationTest / test := (IntegrationTest / test).dependsOn(Docker / publishLocal).value,
IntegrationTest / test := (IntegrationTest / test).dependsOn(Docker / publishLocal).value,
IntegrationTest / testOnly := (IntegrationTest / testOnly).dependsOn(Docker / publishLocal).evaluated
)

lazy val pubsub = project
.settings(pubsubSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile;it->it")
.configs(IntegrationTest)
.in(file("pubsub"))
.settings(buildSettings ++ dynVerSettings)
.aggregate(
pubsubSubs.componentProjects.flatMap(_.referenced): _*
)

lazy val pubsubDistroless = project
.in(file("distroless/pubsub"))
.settings(sourceDirectory := (pubsub / sourceDirectory).value)
.settings(pubsubSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile;it->it")
.configs(IntegrationTest)
val pubsubSubs = new CompositeProject {
override def componentProjects: Seq[Project] =
Seq(
"eclipse-temurin:8-jre",
"eclipse-temurin:11-jre",
"eclipse-temurin:20-jre",
"ibm-semeru-runtimes:open-8-jre",
"ibm-semeru-runtimes:open-11-jre",
"ibm-semeru-runtimes:open-20-jre"
).map { image =>
val i = image.replace(":", "-")
Project(s"""pubsub-${image.replace(":", "-")}""", file(s"""pubsub/$i"""))
.settings(name := s"""pubsub-$i""")
.settings(pubsubSettings)
.settings(dockerBaseImage := image)
.settings(Docker / version := s"${version.value}-${i}")
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile;it->it")
.configs(IntegrationTest)
}
}

// lazy val pubsubDistroless = project
// .in(file("distroless/pubsub"))
// .settings(sourceDirectory := (pubsub / sourceDirectory).value)
// .settings(pubsubSettings)
// .enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
// .dependsOn(http4s % "test->test;compile->compile;it->it")
// .configs(IntegrationTest)

lazy val kafkaSettings =
allSettings ++ buildInfoSettings ++ Seq(
Expand All @@ -250,14 +294,14 @@ lazy val kafkaSettings =

lazy val kafka = project
.settings(kafkaSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")

lazy val kafkaDistroless = project
.in(file("distroless/kafka"))
.settings(sourceDirectory := (kafka / sourceDirectory).value)
.settings(kafkaSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")

lazy val nsqSettings =
Expand All @@ -273,14 +317,14 @@ lazy val nsqSettings =

lazy val nsq = project
.settings(nsqSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")

lazy val nsqDistroless = project
.in(file("distroless/nsq"))
.settings(sourceDirectory := (nsq / sourceDirectory).value)
.settings(nsqSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")

lazy val stdoutSettings =
Expand All @@ -292,14 +336,14 @@ lazy val stdoutSettings =

lazy val stdout = project
.settings(stdoutSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile")

lazy val stdoutDistroless = project
.in(file("distroless/stdout"))
.settings(sourceDirectory := (stdout / sourceDirectory).value)
.settings(stdoutSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(http4s % "test->test;compile->compile")

lazy val rabbitmqSettings =
Expand All @@ -311,12 +355,12 @@ lazy val rabbitmqSettings =

lazy val rabbitmq = project
.settings(rabbitmqSettings)
.enablePlugins(JavaAppPackaging, SnowplowDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")

lazy val rabbitmqDistroless = project
.in(file("distroless/rabbitmq"))
.settings(sourceDirectory := (rabbitmq / sourceDirectory).value)
.settings(rabbitmqSettings)
.enablePlugins(JavaAppPackaging, SnowplowDistrolessDockerPlugin, BuildInfoPlugin)
.enablePlugins(JavaAppPackaging, DockerPlugin, BuildInfoPlugin)
.dependsOn(core % "test->test;compile->compile")
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("com.snowplowanalytics" % "sbt-snowplow-release" % "0.3.0")
// addSbtPlugin("com.snowplowanalytics" % "sbt-snowplow-release" % "0.3.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")

0 comments on commit 909eaae

Please sign in to comment.