How to deploy lagom scala on heroku

104 Views Asked by At

I am beginner in lagom scala api. I have developed rest apis using lagom scala play framework. Now I want to deploy my services on heroku just for live testing purpose. I followed the below link to proceed.

https://www.playframework.com/documentation/2.0/ProductionHeroku

connected source code from github to heroku and deployed. Checked into activity build log I found heroku is running some processes in background. At the starting...

*----> Scala app detected

-----> Installing JDK 1.8... done

-----> Running: sbt compile stage

Downloading sbt launcher for 1.2.8:

From https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.8/sbt-launch-1.2.8.jar

To  /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.2.8/sbt-launch.jar

Downloading sbt launcher 1.2.8 md5 hash:

From https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.8/sbt-launch-1.2.8.jar.md5

To  /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.2.8/sbt-launch.jar.md5

   /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.2.8/sbt-launch.jar: OK

Getting org.scala-sbt sbt 1.2.8 (this may take some time)... *

and after completion it some error detected

   [info] Main Scala API documentation to /tmp/scala_buildpack_build_dir/crud-api/target/scala-2.13/api...

   model contains 11 documentable templates

   [info] Main Scala API documentation successful.

   [info] Packaging /tmp/scala_buildpack_build_dir/crud-api/target/scala-2.13/crud-api_2.13-1.0-SNAPSHOT-javadoc.jar ...

   [info] Done packaging.

   [success] Total time: 9 s, completed Dec 1, 2020 4:01:45 AM

   [error] Expected symbol

   [error] Not a valid command: -

   [error] Expected end of input.

   [error] Expected '--'

   [error] Expected 'debug'

   [error] Expected 'info'

   [error] Expected 'warn'

   [error] Expected 'error'

   [error] Expected 'addPluginSbtFile'

   [error] -Xms512M

   [error]  ^

! ERROR: Failed to run sbt!

   We're sorry this build is failing. If you can't find the issue in application

   code, please submit a ticket so we can help: https://help.heroku.com

   You can also try reverting to the previous version of the buildpack by running:

   $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-scala#previous-version

   

   Thanks,

   Heroku

! Push rejected, failed to compile Scala app.

! Push failed

is there something I am missing. Or If you have any other idea on how to deploy lagom scala api on heroku or any other platform for live testing purpose. Thanks in advance.

1

There are 1 best solutions below

1
On

Deploying Lagom on Heroku is, in general, no possible for one limitation Heroku has: the dynos serving the same service can't connect to each other. Lagom is built on top of Play, but most importantly, on top of Akka Clister. To form a cluster Akka Cluster nodes must talk to each other.

There's a separate issue, which actually triggers the error you saw, which is that Lagom projects are often a monorepo with many services on a single build. Sometimes, a build is just a service API sbt module and the service mplementation module. In any case, deploying to Heroku requires that you push a single service to the Heroku git repo. Therefore, you would have to improve the Play/sbt buildpack to supoort Lagom projects: when a Lagom project is detected, ignore the API module and only deploy the implementation.

But, again, even if you made that buildpack improvement you would still be blocked by the cluster formation impediment caused by the networking separation between the Dynos.