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 cf buildpacks.

Here are a couple different ways of getting this done.

Buildpack-Packager

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:

  1. Create a manifest.yml file 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
    
  2. Create a VERSION file to version the buildpack itself. Contents should just be a semver appropriate to your buildpack.

  3. 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: buildpack-packager --uncached.

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.

Manually Zipping

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 manifest.yml + VERSION files:

$ 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 cf create-buildpack.