开发者

How do you manage multiple Rails applications and services that share code and configuration?

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

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

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

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/servic开发者_Python百科e2
/lib/our_code
/lib/common_js
/lib/common_css
/config/common_configuration_files

Is this a sane way to do it?

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).

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

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


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.

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜