Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy Play Framework based apps

I am new to Play Framework (2.0.4). I have developed a little app and ran it locally on built-in play framework web server. Now I want to deploy it on remote server (APPFOG.COM or any other web server). Can some one guide me how deploy it remotely.

Whether I have to create war file, if so, then guide me how to create it and deploy it on remote server.

If there is some other way, please guide me in this regards.

Thanks in advance

like image 488
Simpanoz Avatar asked Nov 11 '12 14:11

Simpanoz


People also ask

How do I run a Play Framework project?

For running Play Framework applications with Intellij Idea tools you need to download and install Scala plugin. You can run you play-app via command line executing play run under the application root directory.

Is Play Framework backend?

Play comes with two configurable server backends, which handle the low level work of processing HTTP requests and responses to and from TCP/IP packets. Starting in 2.6. x, the default server backend is the Akka HTTP server backend, based on the Akka-HTTP server. Prior to 2.6.


2 Answers

The best place to look at is the Play documentation on Github: https://github.com/playframework/Play20/wiki/Production

In this doc, you'll find several ways to deploy your app on several providers:

  • Standalone
  • Heroku
  • Cloud Foundry
  • CloudBees

But if you want to deploy your Play2 app in a servlet container (ie as a war), take a look at the play2-war-plugin.

like image 122
ndeverge Avatar answered Sep 20 '22 16:09

ndeverge


You don't need to deploy your play app on an application server like tomcat or using a WAR file format. Play already comes with its own bundled server.

For Play version 2.6: "Play now uses the Akka-HTTP server engine as the default backend."

Past versions were using Netty as default. It is still supported but must be explicitly configured.

For deploying your app you need to create a distribution package to do that run on your project home folder:

sbt dist

A binary distribution is created: "This produces a ZIP file containing all JAR files needed to run your application in the target/universal folder of your application.

To run the application, unzip the file on the target server, and then run the script in the bin directory. The name of the script is your application name, and it comes in two versions, a bash shell script, and a windows .bat script."

These are the steps to deploy your app:

  1. Create a distribution package sbt dist
  2. Generate your application secret run: playGenerateSecret
  3. Copy and Unzip the package in your server and Run the app's binary start script and pass the secret as a param:

unzip my-first-app-1.0.zip

my-first-app-1.0/bin/my-first-app -Dplay.http.secret.key=abcdefghijk

Check more details about deployment instructions here.

You may also want to investigate other deployment formats using SBT Native Packager as it provides artifact generating capabilities for various formats including:

  • OS X disk images
  • Microsoft Installer (MSI)
  • RPMs
  • Debian packages
  • System V / init.d and Upstart services in RPM/Debian packages
like image 31
guilhebl Avatar answered Sep 20 '22 16:09

guilhebl