Capistrano is a Ruby-based deployment tool that you’ve probably heard about unless you’ve been living under a rock these past few years. There are plenty of Capistrano-specific tutorials and blog posts out there so I won’t waste your time with that. BUT, there’s not a lot of information regarding deployment for Play Framework applications and nothing specifically for Capistrano other than the documentation provided by the module.
Here are two useful links I got out of the documentation:
- First of all, let’s install Capistrano—that’s easy!
gem install capistrano (you might have to sudo that depending on your local setup)
- Just to make sure the installation occurred correctly, run “cap -V”. You should see something like this come up:
Capistrano v2.9.0
- Now let’s add the dependency to the Capistrano module developed by my friend Pascal (@mandubian on Twitter) who’s also the developer behind Siena. Open up conf/dependencies.yml and add the following:
- play -> capistrano 1.0.0
- Time to tell Play to import the module into your application, so execute the following (and don’t you worry! nobody will have to modify hundreds-of-lines-long pom.xml file!):
play dependencies
- Let’s add support to multiple stages to Capistrano! First execute “gem install capistrano-ext”. Then add the following lines to the very top of conf/deploy.rb:
require 'capistrano/ext/multistage'
set :stages, %w{staging production}
set :default_stage, "staging"
- Now create a configuration file for each enviroment:
config/deploy/staging.rb
role :web, "staging1", "staging2"
config/deploy/production.rb
role :web, "prod1", "prod2"
- Now you need to input some information on conf/deploy.rb so Capistrano knows about your SCM setup, etc. This is what it should look like:
set :application, "Felipe Oliveira Play Framework App"
set :repository, "git@github.com:feliperazeek/myproject.git"
set :scm, :git
set :deploy_to, "/opt/felipera_app"
set :play_path, "/opt/play"
ssh_options[:forward_agent] = true
set :branch, "my_release_branch_1234"
set :shared_path, "#{deploy_to}/shared"
set :app_pid, "#{shared_path}/pids/server.pid"
set :app_path, "#{deploy_to}/current"
set :user, "felipera"
- And finally … Dream Roll please …
cap staging deploy
- … Or Better Yet!
cap production deploy
The module provides more functionality than that. You can always visit the documentation; I don’t want to bore you repeating all that.
Pascal keeps rolling out the goods!
Related articles
- How Boundary does application deployments. (boundary.com)
- Why Did I Fall in Love with Play! Framework? (geeks.aretotally.in)



You must log in to post a comment.
{ 18 trackbacks }