Ruby on Rails:Bundler 和 Ruby on Rails Capistrano:指定部署时要排除哪些组(开发、测试)

发布于 2024-10-29 12:41:12 字数 600 浏览 2 评论 0原文

Bundler 文档说,为了在通过 Capistrano 部署时安装所有必需的捆绑包,只需插入

require 'bundler/capistrano' # siehe http://gembundler.com/deploying.html

他的 deploy.rb 即可。然后,在部署后,Capistrano 会调用

  * executing "bundle install --gemfile .../releases/20110403085518/Gemfile \
    --path .../shared/bundle --deployment --quiet --without development test"

This Works Fine。

但是,我们在生产服务器上有一个暂存设置,与真实的实时站点隔离,我们在其中使用(克隆和防火墙保护的)实时生产数据测试新的应用程序版本。在那里,我们需要安装测试和开发 gem。

如何在此处指定 capistrano 命令行?是否有我可以使用的参数,或者我是否需要设置自己的 capistrano 任务来覆盖 Bundler 的?

谢谢你!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴意少年 2024-11-05 12:41:12

编写不同的任务肯定会保持简单:

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

但是,如果您想使用命令行选项,您可以打开提供的值:

cap deploy target=staging

并且在您的deploy.rb文件中,您可以使用选项值:

if target == "staging"
  set :bundle_without, [:test]
  # do other stuff here
end

还有一个更“适当”的配置您可以使用的对象。我在这里找到了对它的引用: http: //ryandaigle.com/articles/2007/6/22/using-command-line-parameters-w-rake-and-capistrano

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

辞别 2024-11-05 12:41:12

我认为最干净的方法是使用以下命令在部署环境文件中添加 set :bundle_without :

https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension

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

神也荒唐 2024-11-05 12:41:12

我没有独立确认的设置,但是 RAILS_ENV='development' 明白吗?

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文