Getting Started with Cloud Foundry – Sample App

In the previous post we got Pivotal’s version of Cloud Foundry running locally and successfully logged in via the CLI and the web page. Now we want to deploy a sample app.

  1. Download and install the Java SDK
  2. Download and extract the PCF Sping based sample application, Spring Music.
  3. Open a command prompt and navigate to the directory where you extracted the sample app.
  4.  Run “gradlew.bat assemble”. This will build the sample application. Once complete, it will show “BUILD SUCCESSFUL”


  5. The sample application has now been built and and saved as a .jar file to ..\build\libs\spring-music.jar.


  6. In the extracted files, there is a file called manifest.yml. This is needed to tell Cloud Foundry where to find the build that needs to be deployed and other parameters such as memory required for the instances that run the application.


  7. Now we have built our application and checked their is a manifest file, we are ready to push to PCF. Login to PCF Dev using the following command “cf login -a –skip-ssl-validation”. At the Select an Org screen, press 1 to select the pcf-dev-org so this org is used for push operations.


  8. Now run “cf push –hostname spring-music” to push the sample app to PCF Dev.

    This first creates an empty app, a route (dns name for the app), then binds the two together. It uploads the app files and starts the app.


  9. At this point the uploaded app files aren’t actually deployed to the app itself, so if you browse the route that was created you’ll get the following error;


  10. However, the ‘cf push’ command hasn’t finished, as its still running in the background. CF will analyse whats in the app files, what dependencies are required and then download them. It will then spin up a container in a staging area, combine these files together in to a ‘droplet’, then destroy the container.


  11. It then starts the app proper using the droplet created in staging.


  12. To show the status of the app, run ‘cf apps’


  13. You can now browse to the route address and the sample app will display 🙂


There is lots more to do after that, but its a great example of being able to spin up an app really quickly.

These steps are based on Pivotal’s own getting started tutorial which can be found here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s