9

The Bundler documentation says, that in order to install all necessary bundles when deploying via Capistrano, one need only insert

require 'bundler/capistrano' # siehe http://gembundler.com/deploying.html

in his deploy.rb. Then, upon deployment, Capistrano calls

  * executing "bundle install --gemfile .../releases/20110403085518/Gemfile \
    --path .../shared/bundle --deployment --quiet --without development test"

This works fine.

However, we have a staging setup on our production server, isolated from the real live site, where we test a new app release with (cloned and firewalled) live production data. There, we need test and development gems to be installed.

How do I specify the capistrano command line here? Are there parameters I can use, or do I need to set up my own capistrano task to overwrite Bundler's?

Thank you!

Jens
  • 1,386
  • 14
  • 31

3 Answers3

19

Writing different tasks would certainly keep it simple:

task :production do
  # These are default settings
  set :bundle_without, [:development, :test]
end

task :staging do
  set :bundle_without, [:test]
  # set :rails_env, 'staging'
end

However, if you want to use command line options you could switch on the supplied value:

cap deploy target=staging

And inside your deploy.rb file you could use the option value as:

if target == "staging"
  set :bundle_without, [:test]
  # do other stuff here
end

There's also a more 'proper' configuration object that you can use. I've found a reference to it here: http://ryandaigle.com/articles/2007/6/22/using-command-line-parameters-w-rake-and-capistrano

Scott
  • 17,127
  • 5
  • 53
  • 64
  • 3
    I use a Capistrano extension called 'multistage', which allows for different target environments to be specified (in my case, staging and production). Setting :bundle_without fixed my problem for now. Thanks! – Jens Apr 07 '11 at 05:47
  • Since answering this question over a year ago, I now use the capistrano-multistage extension gem too. – Scott Aug 09 '12 at 22:43
3

I think the cleanest way is to just add set :bundle_without in your deploy environment files using this:

https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension

JPN
  • 632
  • 12
  • 24
0

I don't have a setup to independently confirm, but does RAILS_ENV='development' get it?

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130