Managing custom buildpacks in Cloud Foundry
Page last updated:
You can manage additional buildpacks in Cloud Foundry by using the Cloud Foundry Command Line Interface tool (cf CLI).
If your app uses a language or framework that the Cloud Foundry (Cloud Foundry) system buildpacks do not support, you can take one of the following actions:
Write your own buildpack. For more information, see Creating custom buildpacks.
Customize an existing buildpack.
Use a Heroku Third-Party Buildpack.
Add a buildpack
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 [--lifecycle LIFECYCLE]Where:
BUILDPACKspecifies the buildpack name.PATHspecifies the location of the buildpack.PATHcan point to a ZIP file, the URL of a ZIP file, or a local directory.POSITIONspecifies where to place the buildpack in the detection priority list.--lifecycle LIFECYCLE(optional) specifies the lifecycle type for the buildpack. Valid values arebuildpack(the default, for traditional Cloud Foundry buildpacks) andcnb(for Cloud Native Buildpacks). For more information about Cloud Native Buildpacks, see the Cloud Native Buildpacks documentation.
For more information, enter
cf help create-buildpack.To confirm that you have successfully added a buildpack, run:
cf buildpacks [--lifecycle LIFECYCLE]Use
--lifecycle cnbto list only Cloud Native Buildpacks, or--lifecycle buildpackto list only traditional buildpacks.
Update a buildpack
To update a buildpack, run:
cf update-buildpack BUILDPACK [-p PATH] [-i POSITION] [-s STACK][--enable|--disable] [--lock|--unlock] [--rename NEW_NAME] [--lifecycle LIFECYCLE]
Where:
BUILDPACKis the buildpack name.PATHis the location of the buildpack.POSITIONis where the buildpack is in the detection priority list.STACKis the stack that the buildpack uses.--lifecycle LIFECYCLE(optional) specifies the lifecycle type of the buildpack to update. Valid values arebuildpackandcnb. Use this flag when a traditional buildpack and a Cloud Native Buildpack share the same name to disambiguate which one to update.
For more information about updating buildpacks, enter cf help update-buildpack.
Rename a buildpack
To rename a buildpack, run:
cf rename-buildpack BUILDPACK NEW_NAME
Where BUILDPACK is the current buildpack name and NEW_NAME is the new name.
Delete a buildpack
To delete a buildpack, run:
cf delete-buildpack BUILDPACK [-s STACK] [-f] [--lifecycle LIFECYCLE]
Where:
BUILDPACKis the buildpack name.STACKis the stack that the buildpack uses.--lifecycle LIFECYCLE(optional) specifies the lifecycle type of the buildpack to delete. Valid values arebuildpackandcnb. Use this flag when a traditional buildpack and a Cloud Native Buildpack share the same name to disambiguate which one to delete.
For more information about deleting buildpacks, enter cf help delete-buildpack.
Lock and unlock a buildpack
Every new version of Cloud Foundry ships with an updated buildpack. By default, your deployment applies to the most recent buildpack when you upgrade. In some cases, however, you might 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 might 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 Cloud Foundry updates. You must manually unlock them to update them.
If you elect to use the --unlock flag, your deployment applies to the most recent buildpack when you upgrade Cloud Foundry.
cf update-buildpack BUILDPACK [-p PATH] [-i POSITION] [-s STACK] [--enable|--disable] [--lock|--unlock]
This feature is also available through the API. See the locked flag under Update a Buildpack in the Cloud Foundry API documentation.
Deactivate custom buildpacks
You can disable custom buildpacks for an entire deployment by adding disable_custom_buildpacks: true in your Cloud Foundry manifest under properties.cc.