From 5c0fa9862993dcf3dd2a8fc820a48c7c9d8349f1 Mon Sep 17 00:00:00 2001 From: Anton Parkhomenko Date: Thu, 10 Dec 2020 22:59:34 +0300 Subject: [PATCH] RDB Loader: build Docker image (close #247) --- .github/workflows/deploy_loader.yml | 13 ++++++++++--- build.sbt | 3 +++ project/BuildSettings.scala | 21 ++++++++++++++++----- project/plugins.sbt | 3 ++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy_loader.yml b/.github/workflows/deploy_loader.yml index dcf378c25..12196c97f 100644 --- a/.github/workflows/deploy_loader.yml +++ b/.github/workflows/deploy_loader.yml @@ -15,11 +15,18 @@ jobs: with: packages: | release-manager - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 - - name: Build and publish Loader + java-version: 11 + - name: Docker login + run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and publish RDB Loader Docker image + run: sbt "project loader" docker:publish + - name: Build and publish Loader on S3 run: .github/deploy.sh rdb_loader $GITHUB_REF env: AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} diff --git a/build.sbt b/build.sbt index 8f525ae6f..f3b341810 100755 --- a/build.sbt +++ b/build.sbt @@ -43,12 +43,14 @@ lazy val common = project.in(file("modules/common")) lazy val loader = project.in(file("modules/loader")) .settings( name := "snowplow-rdb-loader", + packageName in Docker := "snowplow/snowplow-rdb-loader", initialCommands := "import com.snowplowanalytics.snowplow.rdbloader._", Compile / mainClass := Some("com.snowplowanalytics.snowplow.rdbloader.Main") ) .settings(BuildSettings.buildSettings) .settings(BuildSettings.scalifySettings(shredder / name, shredder / version)) .settings(BuildSettings.assemblySettings) + .settings(BuildSettings.dockerSettings) .settings(resolvers ++= Dependencies.resolutionRepos) .settings( addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), @@ -77,6 +79,7 @@ lazy val loader = project.in(file("modules/loader")) ) ) .dependsOn(common) + .enablePlugins(JavaAppPackaging, DockerPlugin) lazy val shredder = project.in(file("modules/shredder")) .settings( diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index abd1766a2..38672236e 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -19,6 +19,12 @@ import Keys._ import sbtassembly._ import sbtassembly.AssemblyKeys._ +// sbt-native-packager +import com.typesafe.sbt.packager.Keys.{daemonUser, maintainer} +import com.typesafe.sbt.packager.linux.LinuxPlugin.autoImport._ +import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport._ +import com.typesafe.sbt.packager.docker.DockerVersion + import scoverage.ScoverageKeys._ // DynamoDB Local @@ -42,11 +48,6 @@ object BuildSettings { "-encoding", "UTF-8" ), - javacOptions := Seq( - "-source", "1.8", - "-target", "1.8" - ), - addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.10" cross CrossVersion.binary) ) @@ -152,4 +153,14 @@ object BuildSettings { testOnly in Test := (testOnly in Test).dependsOn(startDynamoDBLocal).evaluated, testOptions in Test += dynamoDBLocalTestCleanup.value ) + + lazy val dockerSettings = Seq( + maintainer in Docker := "Snowplow Analytics Ltd. ", + dockerBaseImage := "snowplow-docker-registry.bintray.io/snowplow/base-debian:0.2.1", + daemonUser in Docker := "snowplow", + dockerUpdateLatest := true, + dockerVersion := Some(DockerVersion(18, 9, 0, Some("ce"))), + daemonUserUid in Docker := None, + defaultLinuxInstallLocation in Docker := "/home/snowplow" // must be home directory of daemonUser + ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 75933071c..c889f4904 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,4 +5,5 @@ addSbtPlugin("com.localytics" % "sbt-dynamodb" % "2.0.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") \ No newline at end of file +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.6") \ No newline at end of file