In the past PaaS has been rigid and invasive for application developers. CloudFoundry aims to change that perception of PaaS with the use of Buildpacks. A Buildpack allows an application developer to define his deployment environment in plain text. Some refer to this as infrastructure as code since the aspects of a deployment environment that were previously handled by system administrators on dedicated servers now exist in plain text alongside the application files.
What’s available out-of-the-box?
Before diving into custom buildpacks, a lot of people will ask “What is available out-of-the-box with CloudFoundry?”. The answer is everything and nothing. It’s true that there are some buildpacks that come pre-configured within the CloudFoundry, Stackato or Helion environments. However, it’s not entirely accurate or useful to consider these as “a version available in cloudfoundry”. The article below provides crucial context needed to determine whether or not an application should leverage an out-of-the-box buildpack or customize one.
The process to create custom buildpacks includes the following steps.
- Develop the process to build out the runtime environment
- Understand the staging process
- Create a buildpack that stages the application for deployment
Understand the buildpack staging process
The buildpack staging process comprises all the steps to download, compile, configure and prepare a runtime environment. The result of staging is a droplet (a gzipped tar file) which contains all application and runtime dependencies. When a new docker application container is created, the droplet is used to deploy the application.
Design the runtime environment
Designing the runtime environment should be done using the same docker container that will be used to stage and deploy the application. Helion and Stackato use an Ubuntu based Docker image prepared specifically for the CloudFoundry environment.
Create a buildpack
With steps to produce a runtime environment and an understanding of the staging process, it’s now possible to create a custom buildpack. This includes creating detect, compile and release scripts, in addition to any related files.