Buildpacks

In this exercise, we will examine a running app to understand what a buildpack provides.

View System Buildpacks

Use cf help -a to find out how to take a look at the buildpacks configured in PWS.

If you don’t specify a buildpack, what is the first one that will be tested for?

Pushing with the Static Buildpack

An app is included in the 04-buildpacks/static-app directory.

Push the app in 04-buildpacks/static-app to CF using the provided manifest

How can you check that you pushed your app successfully?

Explore Buildpack Output

How does the running droplet compare to your app directory?

Use cf ssh static-app to explore the filesystem of the running application

Observe what additional dependencies the buildpack made available for your app

Exit the SSH session with the exit command or CTRL+d.

Scale with Speed

Use cf scale to scale your static app to 16 instances

Why is CF able to scale instances so quickly?

Checking Your Work

You can view the details of your app:

$ cf app static-app

     state      since        cpu    memory        disk
#0   running    2015-11-02   0.0%   6.5M of 16M   33.6M of 64M
#1   starting   2015-11-02   0.0%   0 of  16M     0 of 64M
#2   running    2015-11-02   0.0%   6.9M of 16M   33.5M of 64M
...
#14   running   2015-11-02   0.0%   6.8M of 16M   33.5M of 64M
#15   running   2015-11-02   0.0%   7M of 16M     33.6M of 64M

Override the Chosen Buildpack

Cloud Foundry correctly used the Staticfile Buildpack to deploy your app. It did this because the app includes a file called Staticfile.

Change into 04-buildpacks/mixed-app and see that the directory contains both index.html and index.php

Which buildpack do you think will be used to run this app? Staticfile, or PHP?

Use cf push to deploy mixed-app

Observe from the CLI output which buildpack was used

Visit both /index.html and /index.php

Use cf ssh to see what files the buildpack has added

Instead of letting Cloud Foundry allow each buildpack to detect whether it can run the app, we’re going to specify which buildpack we want to use.

Push the app again, using a flag to specify this buildpack: https://github.com/cloudfoundry/staticfile-buildpack (use cf push --help to find out which flag to provide)

Observe from the CLI output which buildpack was used

Visit both /index.html and /index.php

What happens this time? Why?

Use cf ssh to see what files the buildpack has added, and how they differ from the last push

Clean Up

Delete your apps to free up space.

Beyond the Class

© 2018 Copyright Cloud Foundry Foundation. All Rights Reserved.