Olly
Olly

Reputation: 7758

What is the recommended way of vendoring rails for a production application?

Rather than using the latest Rails gem for my application, I like to have the code local in my own git repository, which means putting it in vendor/rails.

There are a couple of ways of doing this: downloading the source for the particular branch/tag I want to run and committing it to my repository, or using git submodules.

Submodules seem like a natural way to go, but isn't it the case that each time you clone the repository you'll have to manually check out the branch you want to use that submodule for (otherwise you'll just get master)? And is there an impact on Capistrano deployments using this method?

Upvotes: 2

Views: 443

Answers (2)

Andy Stewart
Andy Stewart

Reputation: 5498

Capistrano supports submodules and, if you are deploying via remote_cache, deployment is nice and fast. In your deploy.rb you need:

set :git_enable_submodules, true set :deploy_via, :remote_cache

I'm not quite sure what you mean when you ask about cloning the repository. Once you have vendored Rails as a submodule, you can pin it to a specific commit/tag/branch. This stores a kind of distributed symlink (at least that's the way I think of it) in your repo, pointing to the Rails commit in question. When you clone your repo, that commit's tree will be automatically pulled down too (I think!).

I went through this myself a couple of months ago and wrote it up here. It's working well for me.

http://blog.airbladesoftware.com/2009/4/28/how-to-vendor-rails

Upvotes: 1

mixonic
mixonic

Reputation: 2701

I'd recommend freezing on a release:

rake rails:freeze:edge RELEASE=2.3.3

There is a git branch for 2-3-stable, but I've had a terrible time using it. Submodules are a bit of a pain. The tool Braid is pretty nice, but I like freezing Rails with releases.

Capistrano is going to be a little more sluggish deploying your code (the whole Rails codebase is in there), but capistrano itself and your production setup should not need to be altered.

Good luck!

Upvotes: 1

Related Questions