Skip to Content

Deploy Your Node.js App with the Cloud Foundry CLI

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

Deploy Your Node.js App with the Cloud Foundry CLI

January 27, 2021
Created by
September 7, 2018
Prepare your Node.js app to be deployed to the SAP BTP, Cloud Foundry environment with the Cloud Foundry command line interface.

You will learn

  • Which metadata needs to be specified to deploy the Node.js app to SAP Business Technology Platform, Cloud Foundry environment
  • How to check whether the application has successfully been deployed
QR code

Prerequisites


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 BTP, Cloud Foundry environment instance.

Copy the following content to the recently created file:

---
applications:
- 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:

nodetutorial
├── 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 BTP 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 BTP, Cloud Foundry environment space

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

user@host:~/nodetutorial
=> cf push

Note:

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:

user@host:~/nodetutorial
=> 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