Jan 10, 2017 Some options for adding a custom buildpack to CF
I recently needed to make use of the cf-multi-buildpack (UPDATE: there is also an updated GPL-licensed fork of cf-multi-buildpack). Its instructions indicate to use the
-b https://github.com/pl31/cf-multi-buildpack flag during
cf push to make use of it. However, I wanted to make this something available explicitly to all my Cloud Foundry users, and add it as a custom buildpack for all to see with
Here are a couple different ways of getting this done.
buildpack-packager is a ruby gem with the goal of helping you make cached/offline buildpacks, or bundling buildpacks in general. Installation is as simple as
gem install buildpack-packager. Using it is a little more complicated, but still pretty easy:
manifest.ymlfile for your buildpack (to list out the dependencies and how to find them). Mine looked like this, since cf-multi-buildpack doesn't have any dependencies of its own:
language: multi # used for naming your buildpack dependencies:  # List describing all the deps of your buildpack url_to_dependency_map:  # List of regexen to parse name + version of deps exclude_files:  # List of files to not include in the buildpack
VERSIONfile to version the buildpack itself. Contents should just be a semver appropriate to your buildpack.
Build the buildpack. You can build it in cached mode and embed all dependencies:
buildpack-packager --cached. Or, you can build it in uncached mode, and embed no dependencies:
I went with cached mode as it was less typing and I had no dependencies to cache:
$ buildpack-packager --cached Cached buildpack created and saved as /Users/gfranks/code/starkandwayne/cf-multi-buildpack/multi_buildpack-cached-v1.0.zip with a size of 4.0K
From here, adding the buildpack to CloudFoundry was as simple as
cf create-buildpack multi-buildpack 10 multi_buildpack-cached-v1.0.zip.
If your buildpack has no dependencies and is relatively simple, it may be easier to create the buildpack manually from source, rather than create the
$ git clone https://github.com/pl31/cf-multi-buildpack $ cd cf-multi-buildpack $ zip -x *.git* -r multi-buildpack-v1.0.zip . adding: bin/ (stored 0%) adding: bin/compile (deflated 55%) adding: bin/detect (deflated 24%) adding: bin/release (deflated 35%) adding: multi.zip (stored 0%) adding: README.md (deflated 41%)
The resultant zipfile can then be uploaded directly to CF via