Search code examples
scalaplayframework-2.0web-deploymenttypesafe-activatorsbt-native-packager

How to deploy a Scala Play framework API using the SBT native packager


I created a web API based on the Scala Play framework 2. In the past I generated war files using a SBT plugin in order to deploy in production using Tomcat. It is now possible to build native package from Play project using the SBT native packager plugin. I used it to generate a debian package from my web app.

However, I don't understand how it works. I could generate and install the debian package and start the daemon, but my API seems not listening request.

In the first case, Tomcat hosts the war file which contains the Play app and manages the HTTP connection. I have the feeling that there are missing parts in my debian package in order to work properly like the war file under Tomcat.

The question is, how can I use the native packager plugin to deploy a standalone HTTP API? What is responsible to handle HTTP connection? What is missing in my project?

Thanks in advance


Solution

  • Play applications run using their own light weight http server.

    To build a standalone project issue

    sbt dist
    

    or if your using activator

    activator dist
    

    This makes a directory target/universal/your-app.zip

    If you unzip the contents you will find a standalone application structure

    /bin
    /lib
    /conf
    /share
    

    under which you can find shellscripts that launch the server

    bin/your-app
    bin/your-app.bat (windows)
    

    The distribution to a war file appears to have been removed from play. Similar question asked here: Deploy play as a war file into a servlet container, even if it uses JPA heavily?