diff --git a/bootstrap b/bootstrap deleted file mode 100755 index f17e030..0000000 Binary files a/bootstrap and /dev/null differ diff --git a/build.sbt b/build.sbt index b31da7b..6a109a7 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ lazy val root = (project in file(".")) - .enablePlugins(RiffRaffArtifact) + .enablePlugins(RiffRaffArtifact, NativeImagePlugin) .settings( name := "invoicing-api", description := "Zuora Invoice management for supporters (refund, etc.)", @@ -26,6 +26,11 @@ lazy val root = (project in file(".")) "-Xasync" ), Compile / mainClass := Some("bootstrap"), // AWS custom runtime entry point + nativeImageOptions ++= Seq( + "--enable-http", + "--enable-https", + "--no-fallback", + ), ) lazy val deployAwsLambda = inputKey[Unit]("Directly update AWS lambda code from DEV instead of via RiffRaff for faster feedback loop") @@ -45,8 +50,4 @@ deployAwsLambda := { } } -lazy val packageNativeAwsImage = inputKey[Unit]("Build GraalVM native image and package in AWS custom runtime format") -packageNativeAwsImage := { - import scala.sys.process._ - s"sh ${baseDirectory.value}/package.sh" ! -} +addCommandAlias("packageNativeAwsImage", "nativeImageCopy target/scala-2.13/bootstrap") diff --git a/package.sh b/package.sh deleted file mode 100755 index fb2096b..0000000 --- a/package.sh +++ /dev/null @@ -1,17 +0,0 @@ -targetDir=target/scala-2.13 - -echo " - FROM oracle/graalvm-ce:20.3.0-java11 - RUN gu install native-image - WORKDIR /${targetDir} - CMD native-image -jar invoicing-api.jar --enable-url-protocols=https,http --no-fallback --allow-incomplete-classpath bootstrap -" | docker build -f - --tag linux-native-image . -docker run -v "$(pwd -P)/${targetDir}":/${targetDir} linux-native-image -if [ $? -ne 0 ]; then - echo "Failed to build native image" - exit 1 -else - echo "Successfully build native image" - zip -r -j ${targetDir}/invoicing-api.zip ${targetDir}/bootstrap -fi - diff --git a/project/build.properties b/project/build.properties index c19c768..7de0a93 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.2 +sbt.version=1.4.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index ca836c2..589cbf7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("com.gu" % "sbt-riffraff-artifact" % "1.1.9") -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.5") \ No newline at end of file +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.5") +addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.2.2") \ No newline at end of file