Wednesday, October 16, 2013

Play2 and Deploying your app

Play2 and packaging your app


Play apps are easy to start using play console, "~run" command is excellent on development mode, "start" command shows how application behaves on production. 

There remains question, how to prepare distibution packages which are startable without play console?

Packaging with stage and Dist


Play has commands "Stage" and "dist". "Stag"e is preparing app. "Dist" is packaging it to Zip. You can easily package Play2 app to other as Zip package by using universal packager.

Stage


"stage" command can be used to collect sources and store them under "target/universal/stage" directory. Your application is then startable with generated script which is under "bin" directory. Name of script file will be name of your application. If needed config file can be used to customize runtime behavior.

Example flow

  1. play stage
  2. target/universal/stage/bin/<app-name> -Dconfig.file=/full/path/to/conf/application-prod.conf

Dist


"dist" command will package application generated to zip file. Zip file will be located under "target/universal" and is named after your applications name and version number.

Example flow

  1. play dist
  2. .. copy .zip to given location
  3. .. unzip
  4. bin/<app-name> -Dconfig.file=/full/path/to/conf/application-prod.conf

Custom


If you prefer or need some other packaging methods as zip it's possible to use packager directly

Example flow

  1. play universal:package-zip-tarball
  2. .. 

Publishing to Maven repository


"publish" command can be used to publish project. For this you need to define in "build.sbt" where artifact are about to be published (publishTo) and rights needed (credentials) to access given repository.

Example flow
  1. make needed changes to build.sbt
  2. play publish

Further steps


All this is pretty theoretical until you try it. Please do. You'll find more info from here to support your efforts.


No comments: