Array
University of Oregon

Cloud Foundry App 234

In chapter 8, we see how to deploy our web applications to an open source PaaS (Platform-as-a-Service) called Cloud Foundry. The concepts that we’ll learn can be generalized to other PaaS services like Heroku, Nodejitsu, Modulus.io, etc.

Getting Your App Ready for Deployment

Pp. 233-236 describe how to test and deploy a simple app from your VM.

For a simple app, you can test and deploy the app from your computer, without using a VM, and that is what we will do here:

  1. Create a new folder on your computer named 281/projects/p5/lwdev/. Download server-demo.js and package.son of p. 234 to the lwdev folder.
  2. Open lwdev in Sublime.

    Replace yourDuckID-app1 with your actual DuckID username.
    Example: susanq-app1

  3. cd to 281/projects/p5/lwdev/ and use npm to install Express:
    npm install --save express
  4. Start the server:
    node server-demo.js
  5. Open localhost:3000 in Chrome, and view the web page.
    You can stop the server with control-c at the command line.

Deploy Your App to the Cloud

If the app runs locally, then it’s ready to deploy:

  1. Log in and specify the api endpoint we will be using:
    cf login -a api.run.pivotal.io
    
  2. Push your app to Cloud Foundry (p. 236)
    cf push susanq-app1 -m 50M
  3. Open susanq-app1.cfapps.io in Chrome, and on your cell phone

-m: Memory limit requires a unit of measurement: M, MB, G, or GB, in upper case or lower case.

If your app does not deploy successfully, the number can be adjusted upwards incrementally, and does not have to be a power of two.

When the push command succeeds, cf provides the URL where your app is running. susanq-app1.cfapps.io.

Skip to toolbar