Managing Custom Buildpacks

This topic describes how an admin can manage additional buildpacks in Cloud Foundry using the Cloud Foundry Command Line Interface tool (cf CLI). If your application uses a language or framework that the Cloud Foundry system buildpacks do not support, you can take one of the following actions:

Add a Buildpack

Note: You must be a Cloud Foundry admin user to run the commands discussed in this section.

To add a buildpack, run:

$ cf create-buildpack BUILDPACK PATH POSITION

The arguments to cf create-buildpack specify the following:

  • BUILDPACK specifies the buildpack name.

  • PATH specifies the location of the buildpack. PATH can point to a ZIP file, the URL of a ZIP file, or a local directory.

  • POSITION specifies where to place the buildpack in the detection priority list.

For more information, see create-buildpack in the Cloud Foundry CLI Reference Guide.

To confirm that you have successfully added a buildpack, run cf buildpacks.

The following example shows the output from running the cf buildpacks command after an administrator adds a Python buildpack:

$ cf buildpacks
Getting buildpacks...

buildpack          position   enabled   locked   filename
ruby_buildpack     1          true      false    buildpack_ruby_v46-245-g2fc4ad8.zip
nodejs_buildpack   2          true      false    buildpack_nodejs_v8-177-g2b0a5cf.zip
java_buildpack     3          true      false    buildpack_java_v2.1.zip
python_buildpack   4          true      false    buildpack_python_v2.7.6.zip

Rename a Buildpack

To rename a buildpack:

  • cf CLI v7:
    • cf7 update-buildpack --rename BUILDPACK-NAME NEW-BUILDPACK-NAME. Replace BUILDPACK-NAME with the original buildpack name, and NEW-BUILDPACK-NAME with the new buildpack name.
  • cf CLI v6:
    • cf rename-buildpack BUILDPACK-NAME NEW-BUILDPACK-NAME. Replace BUILDPACK-NAME with the original buildpack name, and NEW-BUILDPACK-NAME with the new buildpack name.

For more information about renaming buildpacks, see rename-buildpack in the Cloud Foundry CLI Reference Guide.

Update a Buildpack

To update a buildpack, run:

$ cf update-buildpack BUILDPACK [-p PATH] [-i POSITION] [-s STACK][--enable|--disable] [--lock|--unlock] 

Note: cf CLI v7 removes the cf rename-buildpack command in favor of a --rename option for cf update-buildpack.

For more information about updating buildpacks, see the cf CLI documentation.

Delete a Buildpack

To delete a buildpack, run:

$ cf delete-buildpack BUILDPACK [-s STACK] [-f]

For more information about deleting buildpacks, see delete-buildpack in the Cloud Foundry CLI Reference Guide.

Lock and Unlock a Buildpack

Every new version of Cloud Foundry includes an updated buildpack. By default, your deployment applies the most recent buildpack when you upgrade. In some cases, however, you may want to preserve an existing buildpack, rather than upgrade to the latest version. For example, if an app you deploy depends on a specific component in Buildpack A that is not available in Buildpack B, you may want to continue using Buildpack A.

The --lock flag lets you continue to use your existing buildpack even after you upgrade. Locked buildpacks are not updated when Pivotal Platform updates. You must manually unlock them to update them.

If you elect to use the --unlock flag, your deployment will apply the most recent buildpack when you upgrade Pivotal Platform.

cf update-buildpack BUILDPACK [-p PATH] [-i POSITION] [-s STACK] [--enable|--disable] [--lock|--unlock]

Note: cf CLI v7 removes cf rename-buildpack in favor of a --rename flag for cf update-buildpack.

This feature is also available through the API. For more information, see Lock or unlock a Buildpack in the Cloud Foundry API documentation.

Disabling Custom Buildpacks

You can disable custom buildpacks using the PAS tile. In the App Containers pane, disable the Enable custom buildpacks checkbox, as shown in the image below.

By default, the cf CLI gives developers the option of using a custom buildpack when they deploy apps to PAS. To do so, they use the -b option to provide a custom buildpack URL with the cf push command. Disabling the Enable custom buildpacks checkbox prevents the -b option from being used with external buildpack URLs.

For more information about custom buildpacks, see Buildpacks.