Capistrano: exclude custom bundle groups for production deploy

Posted . Visible to the public.

Capistrano is by default configured to exclude the gems of the groups development and test when deploying to the stages production and staging. Whenever you create custom groups in your Gemfile, make sure to exclude these, if they should not be deployed to the servers. The gems of these groups might not be loaded by rails, however, the deployment process will take longer as the gems will be downloaded and installed to the server.

e.g. to exclude the groups cucumber and deploy, add the following to config/deploy/production.rb and config/deploy/staging.rb respectively:

set :bundle_without, %w{development test cucumber deploy}.join(' ')

Be aware, that gems that belong to two groups, are only excluded, when both of the groups are excluded, e.g. to exclude rspec in the following example, you will have to bundle without test and cucumber:

group :test, :cucumber do
  gem 'rspec'
end
Daniel Straßner
Last edit
Daniel Straßner
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2016-09-12 07:58)