Luc
Luc

Reputation: 17082

Use Capistrano to deploy production and development environments

I have setup Capistrano to deploy my rails app on the production server, this is working fine.

I now need to be able to deploy the same app on a development server. To do this I have created 2 tasks in the config.deploy.rb:

desc "Run on development server" 
task :dev do 
  server "development_server", :web, :app, :db, :primary => true
end 

desc "Run on production server" 
task :production do 
  server "production_server", :web, :app, :db, :primary => true
end

Doing so, to perfom the deployment on dev, I need to isuse:

cap dev deploy

But, I do not manage to tell Capitrano to run the bundle on the correct env, it uses the "--without development test" option where I would need to have "--without test production"

failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /var/be/releases/20120824155742 && bundle install --gemfile /var/be/releases/20120824155742/Gemfile --path /var/be/shared/bundle --deployment --quiet --without development test'" on 192.168.1.10

Any idea how to perform this ?

Also, how can I selectively start thin in development or production env ? Do I need to create a task for each one or is there any special way of doing this ?

Upvotes: 1

Views: 2557

Answers (1)

Charlie Greene
Charlie Greene

Reputation: 465

The best way to do this is to use the Capistrano Multistage extension. This Wiki will explain much better then I could how it is used. The only problem I had, which was small, was figuring out that with:require 'capistrano/ext/multistage' the require 'capistrano' was not needed.

Upvotes: 4

Related Questions