forked from debitoor/ssh-private-key-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the buildpack work with official Heroku multiple buildpacks (deb…
…itoor#1) * Make the buildpack work with official Heroku multiple buildpacks To allow the buildpack to be used with other buildpacks the way Heroku recommends, see https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app, the compile step now creates a `.ssh` directory in the `BUILD_DIR` and only sym-links to it for the duration of the buildpack compilation. Furthermore, this version includes a way to customise the hosts that should be set up for `ssh` by using an environment variable. By default it's connecting to github.com as before. * Update README to include details about usage with heroku-buildpack-multi
- Loading branch information
1 parent
c2225c0
commit e7880b1
Showing
2 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
# ssh-private-key-buildpack | ||
|
||
A heroku buildpack for setting the ssh private key as part of the application build. It's meant to be used with [heroku-buildpack-multi](https://github.com/heroku/heroku-buildpack-multi), before other buildpacks which require the key to be present, like installing private `npm` modules from `github`. | ||
A Heroku buildpack for setting the ssh private key as part of the application build. It's meant to be used as part of a setup [using multiple buildpacks](https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app), so other buildpacks can authenticate with hosts using ssh keys, for instance to install dependencies from private git repositories. | ||
|
||
# Example usage | ||
|
||
Upload the private key to heroku (note that the key needs to be base64 encoded). | ||
## Configure Multiple Buildpacks | ||
### _Option 1:_ Heroku CLI or Dashboard | ||
Add the buildpack to your Heroku app either using the CLI or the Heroku dashboard. The `ssh-private-key-buildpack` needs to run before any buildpack trying to get ssh access. In the following example, it runs before the `heroku/go` buildpack. | ||
|
||
``` | ||
heroku config:set SSH_KEY=$(cat ~/.ssh/id_rsa | base64) | ||
``` | ||
$ heroku buildpacks:set --index 1 https://github.com/debitoor/ssh-private-key-buildpack.git | ||
$ heroku buildpacks:add heroku/go | ||
|
||
Add a `.buildpacks` file (used by `heroku-buildpack-multi`) which contains this and the default node.js buildpack. | ||
### _Option 2:_ Use `heroku-buildpack-multi` | ||
Instead of setting the buildpacks directly with Heroku they can also be configured using a `.buildpacks` in combination with [`heroku-buildpack-multi`]( https://github.com/heroku/heroku-buildpack-multi). | ||
|
||
``` | ||
https://github.com/debitoor/ssh-private-key-buildpack.git#v1.0.0 | ||
https://github.com/heroku/heroku-buildpack-nodejs.git#v75 | ||
``` | ||
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git | ||
The same example given for the CLI use would have the following `.buildpacks` file. | ||
|
||
Now as long as the public key is present on github and the user has the correct permissions, it's possible to install `npm` modules from private `githup` repositories. | ||
$ cat .buildpacks | ||
https://github.com/debitoor/ssh-private-key-buildpack.git | ||
https://github.com/heroku/heroku-buildpack-go | ||
|
||
## Configure SSH Key | ||
|
||
Set the private key environment variable `SSH_KEY` of your Heroku app (note that the key needs to be base64 encoded). | ||
|
||
$ heroku config:set SSH_KEY=$(cat path/to/your/keys/id_rsa | base64) | ||
|
||
By default the buildback adds Github to `known_hosts`. However you can configure your app to allow custom hosts, too. All that's needed is the set `SSH_HOSTS` for you app to a comma-separated list of hosts, e.g. `git@github.com,example.com` | ||
|
||
$ heroku config:set SSH_HOSTS="git@github.com,example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters