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.
- Download and install the Java SDK
- Download and extract the PCF Sping based sample application, Spring Music.
- Open a command prompt and navigate to the directory where you extracted the sample app.
- Run “gradlew.bat assemble”. This will build the sample application. Once complete, it will show “BUILD SUCCESSFUL”
- The sample application has now been built and and saved as a .jar file to ..\build\libs\spring-music.jar.
- 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.
- 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 api.local.pcfdev.io –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.
- 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.
- 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;
- 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.
- It then starts the app proper using the droplet created in staging.
- To show the status of the app, run ‘cf apps’
- 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.