This topic describes how to create custom buildpacks for Pivotal Application Service (PAS).

For more information about how buildpacks work, see the Buildpacks topic.

Package Custom Buildpacks

PAS buildpacks can work with limited or no Internet connectivity.
The buildpack-packager gives the same flexibility to custom buildpacks, enabling them to work in partially or completely disconnected environments.

Use and Share the Packaged Buildpack

After you have packaged your buildpack using buildpack-packager you can use the resulting .zip file locally, or share it with others by uploading it to any network location that is accessible to the CLI. Users can then specify the buildpack with the -b option when they push apps. See Deploying Apps with a Custom Buildpack for details.

Note: Offline buildpack packages may contain proprietary dependencies that require distribution licensing or export control measures. For more information about offline buildpacks, refer to Packaging Dependencies for Offline Buildpacks.

You can also use the cf create-buildpack command to upload the buildpack into your Cloud Foundry deployment, making it accessible without the -b flag:

Specify a Default Version

As of buildpack-packagerversion 2.3.0, you can specify the default version for a dependency by adding a default_versions object to the manifest.yml file.
The default_versions object has two properties, name and version. For example:

Add the default_version object to your manifest, following the rules below. You can find a complete example manifest in the PAS go-buildpack repository.

Run the default_version_for script from the compile-extensions repository, passing the path of your manifest.yml and the dependency name as arguments. The following command uses the example manifest from step 1:

$ ./compile-extensions/bin/default_version_for manifest.yml go 1.6.3

Rules for Specifying a Default Version

The buildpack-packager script validates this object according to the following rules:

You can create at most one entry under default_versions for a single dependency. The following example causes buildpack-packager to fail with an error because the manifest specifies two default versions for the same go dependency.

# Incorrect; will fail to packagedefault_versions:-name:goversion:1.6.3-name:goversion:1.7.5

If you specify a default_version for a dependency, you must also list that dependency and version under the dependencies section of the manifest. The following example causes buildpack-packager to fail with an error because the manifest specifies version: 1.9.2 for the go dependency, but lists version: 1.7.5 under dependencies.

# Incorrect; will fail to packagedefault_versions:-name:goversion:1.9.2dependencies:-name:goversion:1.7.5uri:https://storage.googleapis.com/golang/go1.7.5.linux-amd64.tar.gzmd5:c8cb76e2308c792e2705c2eb1b55de95cf_stacks:-cflinuxfs2

Core Buildpack Communication Contract

This section describes the communication contract followed by the PAS core buildpacks. This contract enables buildpacks to interact with one another, so that developers can use multiple buildpacks with their applications.

Buildpack developers must ensure their custom buildpacks follow the contract.

This section uses the following placeholders:

IDX is the zero-padded index matching the position of the buildpack in the priority list.

MD5 is the MD5 checksum of the buildpack’s URL.

For all buildpacks that supply dependencies via /bin/supply:

The buildpack must create /tmp/deps/IDX/config.yml to provide a name to subsequent buildpacks. This file may also contain miscellaneous configuration for subsequent buildpacks.

The config.yml file should be formatted as follows, replacing BUILDPACK with the name of the buildpack providing dependencies and YAML-OBJECT with the YAML object that contains buildpack-specific configuration:
name: BUILDPACK
config: YAML-OBJECT

The following directories may be created inside of /tmp/deps/IDX/ to provide dependencies to subsequent buildpacks:

/bin: Contains binaries intended for $PATH during staging and launch

/lib: Contains libraries intended for $LD_LIBRARY_PATH during staging and launch

Disable Custom Buildpacks

Note: A common development practice for custom buildpacks is to fork existing buildpacks and sync subsequent patches from upstream. To merge upstream patches to your custom buildpack, use the approach that Github recommends for syncing a fork.