您如何管理共享代码和配置的多个Rails应用程序和服务? [英] How do you manage multiple Rails applications and services that share code and configuration?

查看:67
本文介绍了您如何管理共享代码和配置的多个Rails应用程序和服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个Rails应用程序(还有更多应用程序)。他们分享:

I have four Rails applications (with more coming). They share:


  • 样式表

  • javascripts

  • 3rd派对宝石

  • 一些相同的ActiveRecord模型

  • 我们自己的ruby库

  • 配置/环境变量

  • stylesheets
  • javascripts
  • 3rd party gems
  • some of the same ActiveRecord models
  • our own ruby libraries
  • configuration / environment variables

我还有一堆与上述Rails应用程序交互的Rabbitmq服务。

I also have a bunch of rabbitmq services that interact with the above Rails applications.

我试图弄清楚如何合理地控制所有这些东西。现在,我将所有内容都存储在一个巨型git存储库中,结构如下:

I'm trying to figure out how to sanely version control all this stuff. Right now, I have everything in one giant git repository, structured like:


/sites/rails1
/sites/rails2
/sites/rails3
/services/service1
/services/service2
/services/service2
/lib/our_code
/lib/common_js
/lib/common_css
/config/common_configuration_files

这是一种明智的方法吗?

Is this a sane way to do it?

如果我要将所有内容分解到自己的git项目中,那么每次共享一个gem / library / css文件时,似乎都无法单独更新每个项目

If I were to break everything into their own git project, then it seems like it would suck to individually update each project each time a shared gem/library/css file was updated (with gems/bundler or whatever).

在一个项目中拥有所有内容的不幸之处在于,我无法(轻松地)在Heroku上放置一个应用程序或服务

The unfortunate thing about having everything in one project is that I can't put one app or service on Heroku (easily).

git子树合并可以在这里提供帮助吗?也许每个站点/服务都是其自己的分支?

Could git subtree merging help here? Maybe each site/service is its own branch?

推荐答案

每个项目一个回购协议。共享的内容可以放入自己的存储库中。假设文件结构恒定,则可以使用软文件链接包括这些目录。 Git会尊重这些软文件链接并进行检入,但不会在项目的回购中包含引用的目录。

One repo per project. The shared stuff can go in its own repo. Assuming a constant file structure, you can use soft file links to include those directories. Git will respect those soft file links and check them in, but will not include the referenced directories in the project's repo.

拥有一个大的回购使得您的回购日志很难遵循,因为您将拥有与项目的语义划分无关的分支(即进入Rails应用程序)。当然,如果您想弄清楚特定文件或目录发生了什么,所有信息都是,但是您一般的 git log --name-status 将包含所有项目的信息,这不是所希望的,而且也很难被过滤掉(没有在git之上创建即席系统)。

Having one big repo makes your repos log hard to follow, since you will have branches that don't relate to the semantic divisions of the project (i.e., into Rails apps). Of course, all the information is there if you want to figure out what happened to a particular file or directory, but your general git log --name-status is going to include information on all projects, which is less-than desirable and also kind of hard to filter out (without creating an ad-hoc system on top of git).

这篇关于您如何管理共享代码和配置的多个Rails应用程序和服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆