Gemfury

This add-on is operated by Cloudfury LLC

Install private RubyGems, Python packages, or Node.js modules into your app

Gemfury

Last Updated: 19 March 2014

Table of Contents

Gemfury is an add-on for hosting and installing your private and custom code packages into your Heroku app. Dividing your application into separate packages is a good practice that allows reuse and DRY‘ing of your code across teams, projects, and applications. Gemfury supports RubyGems, Python packages, and NPM modules with more in the works.

Installing the add-on

Gemfury can be attached to a Heroku application via the CLI:

$ heroku addons:add gemfury:hello
-----> Adding gemfury to sharp-mountain-4005... done, v18 (free)

Once Gemfury has been added, a GEMFURY_URL setting will be available in the app configuration. It will contain the URL to your private package server, which can be retrieved using the heroku config command.

$ heroku config:get GEMFURY_URL
https://repo.fury.io/SeCrEt-ToKeN/me/

Upload your packages

Once Gemfury is provisioned you will need to upload your package files. One way is to hit the Upload button on your Gemfury dashboard:

$ heroku addons:open gemfury
Opening gemfury for sharp-mountain-4005…

Or by using curl from the command line:

$ curl -F p1=@your-1.x.gem `heroku config:get GEMFURY_URL`
~~> Processing package upload
    your-1.x.gem ... ok

Using with Ruby, Rails, and Sinatra

Having your application pull gems from your private repository is easy. Just prepend your Gem server URL as a source in your application’s Gemfile (in addition to the original rubygems.org source).

 source 'https://repo.fury.io/SeCrEt-ToKeN/me/'
 source "https://rubygems.org"

If you're seeing problems installing packages from Gemfury, please make sure your Source URL is correct. It's important to include the trailing slash in the URL.

Using with Python

To use Gemfury with your Python application, you’ll need to add your secret Repo-URL as an extra index. You can find this URL on the Gemfury dashboard or by running:

$ echo `heroku config:get GEMFURY_URL`
https://repo.fury.io/SeCrEt-ToKeN/me/

Deploying private packages from Gemfury is as easy as adding one line to the top of your requirements.txt You will still be able to use public packages from PyPI in addition to ones from your Gemfury account.

 --extra-index-url https://repo.fury.io/SeCrEt-ToKeN/me/
 my-package=0.0.1

Using with Node.js

To use Gemfury for private modules in your Node.js application, get your secret Repo-URL from the dashboard or by running:

$ echo `heroku config:get GEMFURY_URL`
https://repo.fury.io/SeCrEt-ToKeN/me/

You have two options to link your private Gemfury registry to your app – one is good for selectively accessing your private packages and the other is a full switch.

Use Gemfury as your default registry

If you’ve decided to stop depending on the public registry and move all your package dependencies to Gemfury, you can do a full registry switch by adding an npm configuration file to the root directory of your Heroku app.

Create the following file {app-dir}/.npmrc

registry = https://repo.fury.io/SeCrEt-ToKeN/me/
strict-ssl = false

Private packages in package.json

Adding Gemfury dependencies into your package.json file will allow you to selectively include private modules in your application. Due to lack of multi-registry support in NPM, you’ll need to link each package directly to the tarball. Your package.json will look like this:

{
    "name": "node-example",
    "version": "0.0.1",
    "dependencies": {
      "my-pkg": "https://repo.fury.io/SeCrEt-ToKeN/me/my-pkg/-/latest.tgz"
    }
}

Construct the tarball URL as follows. You can name a specific module version or use latest.tgz to pull the highest releasable version:

<Repo-URL>/<Package-Name>/-/<Version>.tgz

Migrating between plans

Plan migrations are easy and instant. Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade gemfury:solo
-----> Upgrading gemfury:solo to sharp-mountain-4005... done, v18 ($9/mo)
       Your plan has been updated to: gemfury:solo

Removing the add-on

Gemfury can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:remove gemfury
-----> Removing gemfury from sharp-mountain-4005... done, v20 (free)

Keeping secrets

It’s always a good idea to keep credentials and secret tokens out of your code and your SCM, so we suggest passing your Repo-URL directly from env to your package manager (if possible). Make sure to enable Heroku’s user-env-compile experimental feature to have your environment available during slug compilation. For example, here is the alternative Gemfile addition for private RubyGems:

source ENV['GEMFURY_URL'] if ENV['GEMFURY_URL']

Support

All Gemfury support and runtime issues should be submitted via on of the Heroku Support channels. Any non-support related issues or product feedback is welcome at support@gemfury.com or via Twitter @Gemfury.