开发者

Ruby on Rails: Bundler & Capistrano: specify which groups (development, test) are to be excluded when deploying

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开发者_如何学Python"

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!


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜