在部署中使用 Bundler
这是一个非常基本的问题,但我试图了解如何在部署情况下最好地使用 Bundler。
我正在开发一个 Sinatra 应用程序,它有大约 20 个依赖的 gem。在开发过程中,我将 RVM 与应用程序的自定义 gemset 结合使用,并运行 bundle install
来根据 gemfile 更新 gemset。
当涉及到部署时(目前是手动部署,这样我可以在使用像 capistrano 这样的工具之前了解它是如何工作的),我需要执行 bundle install --development
对吗?这会下载 gem 并将它们放置在 vendor/bundle
中。
我的问题是我还需要做什么?我在服务器上使用 Unicorn - 我是否只需 bundle exec unicorn ...
并且一切正常? (即捆绑程序找到供应商目录并使用那里的 gem?)
unicorn 应该是应用程序中的供应商 gem,还是所有应用程序共享的服务器上的单独“系统”gem?
Pretty fundamental question but I'm trying to understand how best to use Bundler in a deployment situation.
I'm working on a Sinatra application that has about 20 dependent gems. During development, I'm using RVM with a custom gemset for the application, and I run bundle install
to update the gemset in accordance with the gemfile.
When it comes to deployment (manually for now, so I can understand how it all works before using a tool like capistrano), I need to do bundle install --development
right? This downloads the gems and places them in vendor/bundle
.
My question is what else do I need to do? I'm using Unicorn on the server - do I just bundle exec unicorn ...
and everything just works? (i.e. bundler finds the vendor directory and uses the gems from there?)
Should unicorn be a vendored gem in the application or a separate 'system' gem on the server that all applications share?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要 --deployment 密钥,而不是 --development: http://gembundler .com/man/bundle-install.1.html#DEPLOYMENT-MODE
首次运行时,捆绑程序会在 .bundle 目录中创建配置。您可以通过在项目目录中运行
bundle config
或仅cat .bundle/config
来检查它。所以 bundle exec unicorn 就足够了,因为bundler知道gems安装在哪里。在开发机器上,您还可以使用 --path 键将 gems 安装到任意目录。有关更多详细信息,请参阅捆绑安装的联机帮助页(上面的链接或捆绑帮助安装
)。You need --deployment key, not --development: http://gembundler.com/man/bundle-install.1.html#DEPLOYMENT-MODE
On first run bundler creates config in .bundle directory. You can check it by running
bundle config
or justcat .bundle/config
in project's directory. So bundle exec unicorn is enough since bundler knows where gems are installed. On development machine you can also install gems to arbitrary directory using --path key. For more details see manpage for bundle install (link above orbundle help install
).