Previous Lecture Complete and continue  

  Pushing Your First App

In this exercise, you will push an app and add some data to it.

As a developer, I want to easily deploy applications and be able to interact with them.

Pushing the Roster

A roster application has been provided to you as a jar file. This is a simple Spring Boot app, but the process is the same regardless of the language. This app is a RESTful data service with a few other endpoints added for training purposes.

NOTE: As you progress through the course, be sure to follow the directions closely. In most cases, the exercises will build on each other. For this reason, DO NOT delete applications unless instructed to do so.
  • Download the roster application jar file below

Download

  • Use cf push --help to determine how to push your app. Be sure to do the following:
    • Name your app roster
    • Push the jar file by providing the ā€˜-pā€™ flag pointing to the jar file on your laptop
    • Create one instance
    • Allocate 750M of memory
    • Use the java_buildpack buildpack
    • Use --random-route to avoid route collisions

Checking Your Work

If everything is successful, you should see output similar to:

Showing health and status for app roster in org cloudfoundry-training / space development as [email protected]
OK
requested state: started
instances: 1
usage: 750M x 1 instances
urls: roster-rhotic-kiloline.cfapps.io
last uploaded: Wed Nov 29 16:15:31 UTC 2017
stack: unknown
buildpack: java_buildpack
     state     since                    cpu    memory           disk         details
#0   running   2016-07-06 10:16:13 AM   0.0%   252.4M of 750M   155.1M of 1G

Notice the urls value. Your app should now be available here. You can access your application in a browser or via curl.

NOTE: --random-route is a function of the CLI. It appends two random words to the name of your app as a dev tool to help avoid route collisions. DO NOT use this in production.

Add Some Data to Your App

Your app simply stores information about people in key value pairs. It is a REST based application and therefore you can use curl from the command line to put data in.

  • Edit the curl command below with your information:
curl -H "Content-Type: application/json" -X POST -d'{"firstName":"YOUR_FIRST_NAME", "lastName": "YOUR_LAST_NAME", "email":"YOUR_EMAIL"}' http://<YOUR-APP-URL>/people


Windows Users may want to install Postman. The windows command line handles double and single quotes differently. This can make curl requests difficult to write correctly.

NOTE: curl is a general use command line utility. It is not a Cloud Foundry provided tool.

Checking Your Work

At this point, you should see data returned by your app. You can access the /people endpoint via a browser or via curl.

Via curl:

curl http://<YOUR-URL>/people
NOTE: If you use chrome, you might want to install a JSON formatter like JSONView: https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc


Anatomy of a Push


IaaS vs Cloud Foundry

Discussion
0 comments