Skip to Content

Deploy Your Node.js App with the Cloud Foundry CLI

0 %
Deploy Your Node.js App with the Cloud Foundry CLI

Deploy Your Node.js App with the Cloud Foundry CLI

May 8, 2020
Created by
September 7, 2018
Prepare your Node.js app to be deployed to the SAP Cloud Platform with the Cloud Foundry command line interface.

You will learn

  • Which metadata needs to be specified to deploy the Node.js app to Cloud Foundry
  • How to check whether the application has successfully been deployed


Step 1: Create the manifest file

Create a manifest.yaml file in the nodetutorial directory. This file is the deployment descriptor and contains all required information to deploy an application to a SAP Cloud Platform Cloud Foundry instance.

Copy the following content to the recently created file:

- name: myapp
  random-route: true
  path: myapp
  memory: 128M

The property random-route will generate a route, which does not conflict with any other application in the same Cloud Foundry instance.

You should now have the following directory structure:

├── manifest.yaml
└── myapp
    ├── node_modules
    ├── package-lock.json
    ├── package.json
    └── server.js

Explanation for the manifest properties:

Property Name Value
name The application name with which the application will be deployed on Cloud Foundry.
host Where the application (subdomain of the SAP Cloud Platform region) should be reachable.
path The path of the local file system from which the content/artifact has to be deployed.
memory The memory quota which should be allocated for this application.
random-route if this property is set to true, Cloud Foundry will assign a random route (URL) to the application

Refer to the official documentation for more fields of the manifest file.

How can you create your manifest file?
Step 2: Push the app to your SAP Cloud Platform Cloud Foundry space

Make sure you are logged in to your SAP Cloud Platform Cloud Foundry endpoint cf login and navigate to your space via cf space <SPACE>. Execute the following command inside the nodetutorial directory:

=> cf push


Make sure you are logged in via cf login before, otherwise the push command will fail.
The Cloud Foundry command line interface implicitly uses the manifest.yaml file to deploy the application. After the deployment process the status of the application should be displayed in the command line:

command line output app status
Log on to answer question
Step 3: Figure out the application URL

To open the application in a browser, there are two ways to figure out the according URL. You should see the URL in the console output when the deployment has completed.

deployment output app URL

Or you could generally access the application overview. It shows among other information the URL. Accessing the application overview is done via:

=> cf apps
application URL in application overview

Access the URL shown in this list. You should get a 'Hello World' response when accessing the web server at the according URL.

Log on to answer question

Next Steps

Back to top