Production Gems
I’m not sure how I didn’t notice this before, but my deployment on an app was suddenly taking much longer that it had in the past. While I was watching it run, I noticed that when bundle install was running, it was saying installing each gem. I don’t know why I didn’t notice this before. I looked on my server and noticed that each release was about 177mb in size and the vendor/bundle directory was 173mb in size. I was reading the Bundler website when I saw this bit:
“If you use Capistrano, you should symlink vendor/bundle to shared/vendor_bundle so that bundler will share your installed gems between deployments (making things zippy if you didn’t make any changes), but still give you the benefits of isolation from other applications.”
As soon as I read that, I thought why was I never doing this? So I quickly copied all the gems to a shared directory and wrote a new capistrano task. I then did another deploy and it complete in less than a minute. Crazy that I didn’t notice this before. And just goes to show that I still have a lot to learn about Rails.