Capistrano Deployment with Subversion

Capistrano Deployment

Capistrano is a tool used for automation of the application deployment process. Capistrano is mainly used for deploying rails apps. Changes made to the rails app can be easily transferred to the server using cap deploying.

Capistrano can be configured with any version control system like SVN / GIT for deploying an app. Also, we can define application server type (mongrel, mod_rails / Fcgi) on which the app has be deployed in Capistrano.

Here I’m going to discuss cap deploying an app using SVN with Mongrel cluster as the application server.


Capistrano can be installed as a ruby gem as shown below:

$ gem install capistrano

Configuring a rails app to use capistrano:

This can be done by executing the following command from the rails app:

$ capify .

The above command will create a Capfile and config/deploy.rb file.

user@hostname [~/railsapp]$ capify .
[add] writing ‘./Capfile’
[add] writing ‘./config/deploy.rb’

user@hostname [~/railsapp]$ cat Capfile

load ‘deploy’ if respond_to?(:namespace) # cap2 differentiator
Dir[‘vendor/plugins/*/recipes/*.rb’].each { |plugin| load(plugin) }

load ‘config/deploy’ # remove this line to skip loading any of the default tasks

user@hostname [~/railsapp]$ cat config/deploy.rb

set :application, “set your application name here”
set :repository, “set your repository location here”

# If you aren’t deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, “/var/www/#{application}”

# If you aren’t using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

role :app, “your app-server here”
role :web, “your web-server here”
role :db, “your db-server here”, :primary => true

PS: As an alternative, we can directly create Capfile and deploy.rb file under the rails app and load necessary data to it using ‘vi’ editor.

Read More: Capistrano Deployment with Subversion


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s