简体   繁体   English

Ruby on Rails:Bundler和Capistrano:指定在部署时要排除的组(开发,测试)

[英]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.

相关问题 Ruby on Rails:使用capistrano部署时未安装捆绑器 - Ruby on rails: Bundler not installed when deploying using capistrano 使用 capistrano 部署时 Ruby on Rails“KeyError: key not found” - Ruby on Rails "KeyError: key not found" when deploying with capistrano Ruby on Rails:部署时PostgreSQL / Capistrano覆盖了迁移 - Ruby on Rails: PostgreSQL/Capistrano override migration when deploying Ruby On Rails:使用Capistrano 3进行部署时,如何在文件中写入yml配置? - Ruby On Rails: How to write yml configurations in a file when deploying with Capistrano 3? 与Bundler和Capistrano一起部署时遇到问题 - Trouble on deploying with Bundler and Capistrano / usr / bin / env ruby​​没有这样的文件或目录:使用capistrano 3,capistrano / rbenv,capistrano / bundler和capistrano / rails(使用rails 4) - /usr/bin/env ruby no such file or directory: Using capistrano 3, capistrano/rbenv, capistrano/bundler and capistrano/rails (using rails 4) 使用capistrano进行部署,并在rails上使用ruby上传目录 - the deploying with capistrano and uploads directory with ruby on rails 通过Capistrano部署时,捆绑程序在错误的目录中执行 - Bundler executed in wrong directory when deploying via Capistrano 使用 capistrano 部署时,Bundler 找不到“whenever” gem - Bundler cannot find `whenever` gem, when deploying using capistrano Capistrano和捆绑器的导轨 - rails with capistrano and bundler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM