Capistrano is designed to deploy your Rails application (yes it can handle others, but more work is required) to production. However, most applications need to be deployed to more than one environment. For example, we deploy to a staging environment in addition to production. This lets select users and internal employees kick the tires before we release it in the wild. After many complaints, capistrano-ext was born. I am all in favor of using plug ins, but this is such a trivial issue, it’s easier to add the code than worry about the plugin.
set :stage, "staging" unless variables[:stage] set :deploy_to, "/var/www/#{application}" case stage when "staging" set :rails_env, "staging" role :web, "staging.example.com" role :app, "staging.example.com" role :db, "staging.example.com", :primary => true when "production" set :rails_env, "production" role :web, "production.example.com" role :app, "production.example.com" role :db, "production.example.com", :primary => true end
To deploy to the correct environment call capistrano:
$ cap deploy -S stage=staging
If your staging and production share the same machine (not the best idea):
set :stage, "staging" unless variables[:stage] server "example.com", :app, :web: db case stage when "staging" set :rails_env, "staging" set :deploy_to, "/var/www/staging-#{application}" when "production" set :rails_env, "production" set :deploy_to, "/var/www/production-#{application}" end
