[英]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 Bundler文档说,为了在通过Capistrano进行部署时安装所有必需的捆绑软件,只需插入
require 'bundler/capistrano' # siehe http://gembundler.com/deploying.html
in his deploy.rb. 在他的deploy.rb中。 Then, upon deployment, Capistrano calls 然后,在部署后,Capistrano致电
* 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? 如何在此处指定capistrano命令行? Are there parameters I can use, or do I need to set up my own capistrano task to overwrite Bundler's? 是否可以使用参数,还是需要设置自己的capistrano任务来覆盖Bundler的参数?
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: 在您的deploy.rb文件中,您可以将option值用作:
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 我在这里找到了对它的引用: 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: 我认为最干净的方法是使用以下命令在您的部署环境文件中仅添加set:bundle_without:
https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
我没有独立确认的设置,但是RAILS_ENV ='development'可以得到它吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.