Cloud Foundry for Developers: Pushing Apps


After following the first four blogs in this series previewing the  Cloud Foundry for Developers training course, you should have a Cloud Foundry instance to use, have the cf CLI installed, and know how to connect to your instance and run commands. Now it’s time to push an app to your Cloud Foundry instance. You can catch up on the previous articles here:

Part 1: Introduction

Part 2: Definitions

Part 3: Architecture

Part 4: The cf Command

For more details, you can download the sample chapter here

Writing an app is beyond the scope of this series, but  you can refer to the Developer Guide for detailed help. Apps must have unique names, so don’t name it my-app, demo-app, test-app, sample-app, or any other commonly used name for testing.

Pushing Apps

Use the cf push command to deploy your app to your Cloud Foundry instance. If your app requires other services, such as a database, log management, or messaging, the services must be already provisioned, and may need to be bound to your app. See the Deploy an Application to learn more.

A lot of things happen when you push your app:

  • Cloud Foundry uploads and stores your app files
  • Reads and stores app metadata
  • Creates a droplet, the CF unit of execution
  • Assigns the droplet to a Diego cell
  • Starts the app

Writing your app is the hard part. Pushing it is easy. Change to the directory it is in and run cf push. You will see a lot of output as it is deployed. When it is finished, you can run cf apps to list all the apps in your space.

$ cf apps
name               state   instances memory disk urls
mine-fine-ruby-app started 1/1       64M    512M

Run cf app [appname] to see some details of your running app.

$ cf app mine-fine-ruby-app
requested state: started
instances: 1/1
usage: 64M x 1 instances
last uploaded: Mon Apr 9 8:49:11 UTC 2018
stack: cflinuxfs2
buildpack: ruby_buildpack

     state     since        cpu    memory         disk
#0   running   2018-04-09   0.0%   25.7M of 64M   102.4M of 512M

What is your app doing? Tail its logfile, or dump the log instead of tailing. Ctrl+c stops tailing.

$ cf logs mine-fine-ruby-app
$ cf logs --recent mine-fine-ruby-app

Apps can be stopped, started, and restarted.

$ cf stop mine-fine-ruby-app
$ cf start mine-fine-ruby-app
$ cf restart mine-fine-ruby-app

You may delete your app, force delete it, or delete your app and its mapped routes.

$ cf delete mine-fine-ruby-app
$ cf delete mine-fine-ruby-app -f
$ cf delete mine-fine-ruby-app -r

Now you know the basics of using Cloud Foundry to deploy apps. See the Cloud Foundry Documentation for thorough help and tutorials. 

The information in this series is based on the Cloud Foundry for Developers (LFD232) training course from Cloud Foundry and The Linux Foundation. You can download a sample chapter here.