Install capistrano gem
group :test, :development do gem 'capistrano' end
Install capistrano with rvm
Prepare your Project for Capistrano
Capify your project. The following command initialise your project with Capistrano.
$ capify .
Do proper modificatons in Capistrano Recipe (config/deploy.rb)
Lets do the deployment for staging environment.
Create a ruby file under config/deploy/ folder named staging.rb
Copy the following content
set :domain, "mydomain.in" role :app, domain role :web, domain role :db, domain, :primary => true role :resque_worker, domain # if you are using workers in your project, set role for them if needed role :resque_scheduler, domain # if you are using workers in your project set :deploy_to, "/home/my_deploy_path/" # the deployment directory set :environment, "staging" set :rails_env, "staging" set :branch, "staging" set :previous_environment, "develop"
Setup capistrano in deployment server
$ cap staging deploy:setup
This will Create folder structure that capistrano uses in the process.
Make sure that everything is set up correctly on the server by the command
$ cap staging deploy:check
Now you can see a message like:
“You appear to have all necessary dependencies installed”
Create shared/config folder in your deploy_to path
and copy database.yml and other config files as you written in the symlink_shared task in cap recipie (if any)
Deploy your project:
cap staging deploy