We bumped into an issue lately, while deploying one of our major app in the production environment. Just when we tried to run the command
$ bundle install
We realized that the rubygems repository was facing a downtime. Hence we were not able to install gems on our production server, which in turn caused a downtime on our side. In order to overcome this issue we took the decision of caching our gems into our application’s repository(i.e. vendor/cache directory). Below are the steps that we took:
Step 1: On your local machine run the command below
$ bundle package
This command will copy all the .gem files and their respective dependencies in your bundle into the
vendor/cache directory of your rails application.
Step 2: Now after committing your code and running the bundle install command on your production servers, run the command below:
$ bundle install --local
--local parameter will fetch the gems only inside the
vendor/cache directory of your rails application. Hence not hitting the rubygems servers.
This proves to be very helpful in cases where you want quick deployments on your servers.