Giter Site home page Giter Site logo

heroku-buildpack-ssh-deploy-from-private-git-ssh-repos's Introduction

#Usage

##1. Generate a new pair of keys just for that

It's not the safest deployment method (ssh private keys in environment variables !) , so you'd better generate a pair of deployment keys just for the occasion

$ ssh-keygen -f ~/.ssh/heroku

##2. Setup your deploy keys on the private repos you're using

Configure the public deploy key (the "~/.ssh/heroku.pub" one ) within your gitlab / github / bitbucket (please check the corresponding documentation)...

##3. Setup your deploy key within heroku

a. Set your deploy keys with heroku toolbelt from within your app dir

$ heroku config:set SSH_DEPLOY_KEY_PRIV="$(cat ~/.ssh/heroku)"
$ heroku config:set SSH_DEPLOY_KEY_PUB="$(cat ~/.ssh/heroku.pub)"

b. This buildpack is to be chained at the beginning of a multi-buildpacks buildpacks chain like this one

$ heroku buildpack:set https://github.com/heroku/heroku-buildpack-multi.git
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-multi.git

c. Create your .buildpacks file : here for a nodejs app

$ cat .buildpacks
https://github.com/levequej/heroku-buildpack-ssh-deploy-from-private-git-ssh-repos.git
https://github.com/heroku/heroku-buildpack-nodejs.git

##4 Deal with git management in your package manager here for NPM

$cat .npmrc
git=${PWD}/.ssh/git-ssh-command.sh

UPDATE : or you could also use the envvar npm_config_git like so (I like it better b/c it does not interfere with your local build, and you do not need a different .npmrc in your heroku branch if you've got one

$ heroku config:set npm_config_git="\${PWD}/.ssh/git-ssh-command.sh"

All comments & suggestions are welcome

There must be a better way to solve this simple problem and maybe I'd better just have forked the nodejs official buildpack : I don't know I did not check it, but I needed a quick solution for my first heroku app to work asap ,and I came up with that, it works and its portable.

I guess if you use a github private repo you'd much better use a OAuth token for you own safety.

Tested on linux with a private bitbucket repo (I do not think they have Oauth for non team repos : do they ?)

heroku-buildpack-ssh-deploy-from-private-git-ssh-repos's People

Contributors

levequej avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.