简体   繁体   English

Bundler和JRuby的Rails部署策略

[英]Rails deployment strategies with Bundler and JRuby

I have a jruby rails app and I've just started using bundler for gem dependency management. 我有一个jruby rails应用程序,我刚开始使用bundler进行gem依赖管理。 I'm interested in hearing peoples' opinions on deployment strategies. 我有兴趣听取人们对部署策略的意见。 The docs say that bundle package will package your gems locally so you don't have to fetch them on the server (and I believe warbler does this by default), but I personally think (for us) this is not the way to go as our deployed code (in our case a WAR file) becomes much larger. 文档说bundle package会将您的gem打包在本地,因此您不必在服务器上获取它们(我相信warbler默认情况下会这样做),但是我个人认为(对我们而言)这不是可行的方法我们部署的代码(在本例中为WAR文件)变得更大。

My preference would be to mimic our MVN setup which fetches all dependencies directly on the server AFTER the code has been copied there. 我的偏好是模仿我们的MVN设置,该代码将代码复制到服务器后直接在服务器上获取所有依赖项。 Here's what I'm thinking, all comments are appreciated: 这就是我的想法,所有评论都值得赞赏:

Step1: Build war file, copy to server 第一步:建立war文件,复制到服务器
Step2: Unpack war on server, fetch java dependencies with mvn Step3: use Bundler to fetch Gem deps (Where should these be placed??) 第2步:在服务器上解压战争,使用mvn获取Java依赖项第3步:使用Bundler提取Gem deps(这些应该放在哪里?
* Step 3 is the step I'm a bit unclear on. *步骤3是我不清楚的步骤。 Do I run bundle install with a particular target in mind?? 我是否在考虑特定目标的情况下运行bundle install
Step4: Restart Tomcat 步骤4:重新启动Tomcat

Again my reasoning here is that I'd like to keep the dependencies separate from the code at deploy time. 再次,我的理由是我想在部署时将依赖项与代码分开。 I'd also like to place all gem dependencies in the app itself so they are contained, rather than installing them in the app user's home directory (as, again, I believe is the default for Bundler) 我还想将所有gem依赖项放置在应用程序本身中,以便包含它们,而不是将它们安装在应用程序用户的主目录中(同样,我相信这是Bundler的默认设置)

Just looking at the default structure from Warbler it copies gems into Rails.root/gems , so I just decided to follow that convention. 仅查看Warbler的默认结构,它将gems复制到Rails.root/gems ,所以我决定遵循该约定。

*Note: I don't see anywhere that defines this path as a load path for Rails, but it obviously works. *注意:我看不到任何将此路径定义为Rails的加载路径的地方,但是显然可以。 Here's my final solution: 这是我的最终解决方案:

Step1: Build war file, copy to server
Step2: Unpack war on server, fetch java dependencies with mvn 
Step3: use Bundler to fetch Gem deps: `bundle install gems --without test --disable-shared-gems`
Step4: Restart Tomcat

Also note that bundle install gems looks like a specific command ie. 另请注意, bundle install gems看起来像特定命令,即。 "Install these gems" but the gems is actually referring to the directory gems in Rails.root. “安装这些gems”,但是这些gems实际上是指Rails.root中的目录gems。 This directory is created by bundler so doesn't need to exist on deploy. 该目录由捆绑器创建,因此在部署时不需要存在。

Hope that helps anyone else looking for a similar solution! 希望对其他寻求类似解决方案的人有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM