Monday, 8 December 2014

Typesafe activator , play framework applications deployed to Pivotal Cloud Foundry

I decided to quickly build an application using Typesafe activator for a play framework scala application and deploy it to Pivotal Cloud Foundry. You can read more about Typesafe activator below.

Here are the steps to deploy a scala play framework application created using Typesafe activator. I created a basic hello world scala application with the play framework. The purpose here is what is needed to get it deployed on Pivotal Cloud Foundry.

Note: Assumes we have created an application with name "hello-play-scala" and we are in that actually directly as we create files for deployment.

1. Create a distribution ZIP file as follows once you have finished developing your application

> ./activator dist

2. Create a manifest file as follows which refers to the DIST zip file created in #1 above.

- name: pas-helloworld-scala
  memory: 756M
  instances: 1
  host: pas-helloworld-scala
  path: ./target/universal/

3. Create a file, make it executable. This simple shell script is going to call sbt/activator

java -jar activator-launch-1.2.12.jar dist

4. Deploy as shown below.

[Mon Dec 08 10:31:14 papicella@:~/vmware/software/scala/apps/hello-play-scala ] $ cf push -f manifest.yml
Using manifest file manifest.yml

Creating app pas-helloworld-scala in org ANZ / space development as pas...

Using route
Binding to pas-helloworld-scala...

Uploading pas-helloworld-scala...
Uploading app files from: target/universal/
Uploading 1.1M, 131 files

Starting app pas-helloworld-scala in org ANZ / space development as pas...
-----> Downloaded app package (26M)
-----> Java Buildpack Version: v2.4 (offline) |
-----> Downloading Open Jdk JRE 1.7.0_60 from (found in cache)
       Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (0.9s)
-----> Downloading Play Framework Auto Reconfiguration 1.4.0_RELEASE from (found in cache)

-----> Uploading droplet (57M)

1 of 1 instances running

App started

Showing health and status for app pas-helloworld-scala in org ANZ / space development as pas...

requested state: started
instances: 1/1
usage: 756M x 1 instances

     state     since                    cpu    memory           disk
#0   running   2014-12-08 10:32:27 AM   0.0%   164.6M of 756M   118.8M of 1G

5. Finally access in a browser

No comments: