How to use bundler if the target node has no internet connection?
11 Feb 2016
You might be asking, "How can I use bundler to make dependencies work on a server without an internet connection?"
Now, the reason for that could be security — you don’t want an internal app to ever reach out to the outer world, for security reasons or otherwise.
The good news is, that is easily achieved following these three steps:
-
On your development machine, cache the gems required by your applications into
vendor/cache
directory:bundle package --all --all-platforms
This will package all required gems into
vendor/cache
, for all platforms (that ensures that using different platforms for development and deployment won't be an issue).Remember to run that command any time you update dependencies.
-
Make sure
vendor/cache
is checked into source control so that the offline machine can use it to install the gems. -
Once deployed to the node without internet, run
bundle install --local
It will use the cached gems and not try to go to rubygems.org.
Boom. That's it! Your intranet app is good now!