Skip to content

Instantly share code, notes, and snippets.

@kevcha
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevcha/f8a785f023dfd7aae9b0 to your computer and use it in GitHub Desktop.
Save kevcha/f8a785f023dfd7aae9b0 to your computer and use it in GitHub Desktop.
Deploying pivate gems on Heroku

Deploying private gems on heroku

Heroku is a incredible tool for deploying web apps in minutes. The problem comes when you want to deploy an with a private gem.

Here are the solutions I've found browsing the web

Vendorize your gem in your app

  • Unpacking your gem in vendor/your_gem and link it in Gemfile :
gem 'your_gem', path: 'vendor/your_gem

Pros : Easy solution, clean.

Cons : You cannot update your gem with a simple bundler update. You need to build new version of your gem then unpack this new version in your app.

  • Using git subtree :
git subtree add --squash --prefix 'vendor/your_gem' 'git@github.com:user_or_team/your_gem.git' 'master'

And in the Gemfile :

gem 'your_gem', path: 'vendor/your_gem

This will create a git subtree for your gem in vendor/your_gems, squashing all commit history for master branch for your gem into one, and merge it with current app history.

Pros : Easy to use. Updating your gem can be done with a simple git subtree pull --squash --prefix 'vendor/your_gem' 'git@github.com:user_or_team/your_gem.git' 'master'

Cons : It mess up your app commit history with a squash commit and a merge commit each time you add or pull.

Use Github OAuth's access

Create a Github user with access to the repo gem. Create an Github OAuth token for this user. It's dead simple to do this over the Github API just using curl (see http://developer.github.com/v3/oauth/#oauth-authorizations-api for more). Add the token to the git url in your Gemfile :

gem 'your_gem', git: 'https://xxx123abc:x-oauth-basic@github.com/user_or_team/your_gem.git'

Pros : Easy to use, easy to update, all mamanged by bundler.

Cons : Need you to expose OAuth token in Gemfile & Gemfile.lock.

Create your own gemserver

see http://guides.rubygems.org/run-your-own-gem-server/

Use Gemfury : You upload you gem on gemfury

Gemfury is a tool to manage your private Gem. There are several plans, and it's designed to work great with bundler & heroku. For more information, just see Gemfury official documentation and heroku docuementation about Gemfury

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment