Search This Blog

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.

https://typesafe.com/activator

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.

applications:
- name: pas-helloworld-scala
  memory: 756M
  instances: 1
  host: pas-helloworld-scala
  domain: apj.fe.pivotal.io
  path: ./target/universal/hello-play-scala-1.0-SNAPSHOT.zip

3. Create a build.sh 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...
OK

Using route pas-helloworld-scala.apj.fe.pivotal.io
Binding pas-helloworld-scala.apj.fe.pivotal.io to pas-helloworld-scala...
OK

Uploading pas-helloworld-scala...
Uploading app files from: target/universal/hello-play-scala-1.0-SNAPSHOT.zip
Uploading 1.1M, 131 files
OK

Starting app pas-helloworld-scala in org ANZ / space development as pas...
OK
-----> Downloaded app package (26M)
-----> Java Buildpack Version: v2.4 (offline) | https://github.com/cloudfoundry/java-buildpack.git#7cdcf1a
-----> Downloading Open Jdk JRE 1.7.0_60 from http://download.run.pivotal.io/openjdk/lucid/x86_64/openjdk-1.7.0_60.tar.gz (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 http://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.4.0_RELEASE.jar (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...
OK

requested state: started
instances: 1/1
usage: 756M x 1 instances
urls: pas-helloworld-scala.apj.fe.pivotal.io

     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: