Buildpacks are a key feature in Bluemix because they provide the runtime for your application. When I have been presenting Bluemix to IBM partners across Europe over the past few months I often get questions about how to specify a buildpack or how to determine what buildpack an application uses, so I thought I'd post this blog to help you understand how they work.
When you deploy your application, the only mandatory information you need to supply is the application name – all other properties use defaults or values determined during the deploy process. If a buildpack is not specified at deploy time, Bluemix uses the standard CloudFoundry process to assign a buildpack from the pre-configured buildpacks. If no pre-configured buildpack can run your application an error is returned. To see what buildpacks are pre-configured you can use the cf buildpacks command from the Command Line Interface :
cf buildpacks Getting buildpacks... buildpack position enabled locked filename noop-buildpack 3 true false noop-buildpack-20140311-1519.zip java_buildpack 4 true false buildpack_java_v2.1.zip ruby_buildpack 5 true false buildpack_ruby_v46-245-g2fc4ad8.zip nodejs_buildpack 6 true false buildpack_nodejs_v8-177-g2b0a5cf.zip liberty-for-java_v20140616-1725 7 true false buildpack_liberty-for-java_v1-20140616-1725.zip sdk-for-nodejs_v20140617-2114 8 true false buildpack_sdk-for-nodejs_v1-20140617-2114.zip sdk-for-nodejs 2 true false buildpack_sdk-for-nodejs_v1-20140620-1640.zip liberty-for-java 1 true false buildpack_liberty-for-java_v1-20140623-1513.zip
The buildpack with the lowest position number that is able to run your application is selected.
If you don't want the platform to select the buildpack for your application you can specify it at deploy time, either on the command line or in a manifest.yml file. When specifying a buildpack you can use the name of a pre-configured buildpack (first column returned from cf buildpacks) or the URL of an external buildpack. CloudFoundry maintains a list of available public buildpacks.
As an example, if I want to use the pre-configured community Node.js buildpack I use the -b option on the command line:
cf push myApp -b nodejs_buildpack
If I have a manifest.yml file I specify the buildpack in the manifest.yml file:
--- applications: - name: myApp buildpack: nodejs_buildpack
If I have a php application that I want to deploy to Bluemix, there are no pre-configured buildpacks available, so I find a php runtime from the CloudFoundry list and specify it a deploy time on the command line:
cf push myApp -b https://github.com/dmikusa-pivotal/cf-php-build-pack.git
or in the manifest.yml file:
--- applications: - name: myApp buildpack: https://github.com/dmikusa-pivotal/cf-php-build-pack.git
If you have questions about buildpacks in Bluemix or other areas of Bluemix you would like to know more about, please comment on this blog post. If you want to try Bluemix you can get a free trial at https://ibm.biz/blog2BM