bitbucket private repository on heroku

前端 未结 4 2225
遇见更好的自我
遇见更好的自我 2021-02-02 17:42

I have a rails app which requires a gem. I host this gem on bitbucket in a private repository.

In my Gemfile I added the gem like following:

gem \"my-gem         


        
4条回答
  •  忘掉有多难
    2021-02-02 18:25

    I had the same problem, but I ended up doing the following as a workaround to providing the Bitbucket password in the Gemfile.

    The basic idea is to clone the gem from Bitbucket into a local directory, add it to your app and package it into vendor/cache so Heroku can use it. My exact steps are below:

    1. Clone your gem to a local directory:

      git clone git@bitbucket.org:me/my_private_gem.git /home/me/my_private_gem

    2. Add the gem to your Gemfile as a 'fake' Bitbucket repo:

      gem 'my_private_gem', :git => 'git@bitbucket.org:me/my_private_gem.git', :branch => 'master' # this repo will not be used

    3. Configure Bundler to work against the local repository (where you cloned the gem in step 1):

      bundle config local.my_private_gem /home/me/my_private_gem

    4. Run bundle install as usual, you should see something like this:

      Using my_private_gem (0.0.1) from git@bitbucket.org:me/my_private_gem.git (at /home/me/my_private_gem)

    5. Package all your gems into /vendor

      bundle package --all

    6. Add /vendor to your repo

      git add vendor && git commit -m 'add my_private_gem to /vendor/cache'

    7. Push to Heroku (don't forget to commit your updated Gemfile and Gemfile.lock first), you should see something like the following:

      Using my_private_gem (0.0.1) from git://github.com/my_private_gem/my_private_gem.git (at /tmp/build_19fmj3tup0zy2/vendor/cache/my_private_gem-8bc6f436e2c8)

    References:

    • Bundler - Local Git Repos
    • Bundler - package

提交回复
热议问题