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

3

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!

Agio answered 3/4, 2011 at 16:1 Comment(0)
Z
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

Zizith answered 3/4, 2011 at 16:46 Comment(2)
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!Agio
Since answering this question over a year ago, I now use the capistrano-multistage extension gem too.Zizith
K
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

Kanya answered 27/7, 2013 at 8:34 Comment(0)
A
0

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

Ardithardme answered 3/4, 2011 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.