如何处理带有子模块的 Rails 应用程序部署?
我最近将几个插件转换为子模块,并意识到当您“git克隆”存储库时,子模块目录将为空。 这对于联合开发人员初始化其子模块和更新是有意义的。
但是,当我使用 capistrano 进行部署时,子模块代码显然不会被部署,这会导致问题。 我可以进入发布分支并初始化并更新那里的模块,但这显然不是一个理想的解决方案。
有人对如何处理这个问题有建议吗? 它像 capistrano 任务一样简单吗?
我在生产方面有点菜鸟。
谢谢你!
I recently turned a couple of my plugins into submodules and realized that when you "git clone" a repository, the submodule directory will be empty. This makes sense for co-developers to initialize their submodules and update.
However, when I deploy with capistrano the submodule code will obviously not be deployed which causes problems. I could go into the release branch and init and update the module there, but that is obviously not an ideal solution.
Does anyone have suggestions about how to handle this? Is it as simple as a capistrano task?
I am a bit of a noob on the production side of things.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 这个最近的帖子,capistrano 应该能够初始化并更新您的子模块
:如果您的 .gitmodules 条目是最新的,config/deploy.rb 应该足够了。
您可能需要 修补 Capistrano (
lib/ capistano/recipes/deploy/scm/git.rb
) 以确保您的子模块被包含在内。如果您有嵌套子模块< /strong>,您需要:
只需在部署配置中要求它:
require 'capistrano/deepmodules'
According to this recent thread, capistrano should be able to init and update your submodules:
in config/deploy.rb should be enough, if your
.gitmodules
entries are up to date.You may need to patch Capistrano (
lib/capistano/recipes/deploy/scm/git.rb
) to make sure your submodules get included though.If you have nested submodules, you need:
Just require it at your deployment config:
require 'capistrano/deepmodules'
如果没有这个选项,
set :git_enable_submodules, 1
本身就不起作用:这似乎没有在任何地方记录下来,我花了一段时间才弄清楚。 无论如何,即使没有子模块,拥有该选项通常也很好。
set :git_enable_submodules, 1
on it's own didn't work without this option:This didn't appear to be documented anywhere and took me a while to figure out. It's generally good to have that option anyway, even without submodules.
通过此提交,Capistrano 支持 Git 子模块和内置的 --recursive 选项。要启用 Git 子模块支持,请将其添加到您的
deploy.rb
文件中:set :git_enable_submodules, true
如果您使用 递归 Git 子模块,也添加以下内容:
set :git_submodules_recursive, true
With this commit, Capistrano has support for both Git submodules and the --recursive option baked in. To enable Git submodules support, add this to your
deploy.rb
file:set :git_enable_submodules, true
And if you use recursive Git submodules, add this as well:
set :git_submodules_recursive, true