As we know SAP announced the general availability of Cloud Foundry environment within the SAP Cloud Platform. This means that there is support for several run times and programming languages. What to do if you have a use case where you want to deploy SAPUI5 application on Cloud Foundry environment ?
This is possible using Node.js runtime. In this tutorial, you will see how SAPUI5 application can be deployed on Cloud foundry environment within SAP Cloud platform using Node.js as runtime container.
You have to perform following steps:
Step 1. Clone the source code from GitHub repository
Step 2. Install packages using package.json file
Step 3. Deploy application on Cloud Foundry environment
Pre-requisites:
You have signed up for a trial space on a
Cloud Foundry instance and downloaded and installed Cloud Foundry CLI and logged on to the Cloud foundry instance as
explained here
You have
Node.js and npm installed.
Step 1. Clone the source code from GitHub repository
Clone this
Git repository and
import the project into the Eclipse workspace.
After successful import the project structure should look like this
Note: The pre-requisite for this step is that
EGit Plugin must be installed in Eclipse.
package.json file
This file holds information related to the metadata of project and also handles project’s dependencies.
app.js file
The very first script command in package.json file is to run
node app.js.
This app.js file contains information about the how to use express framework to set up middleware to respond to HTTP Requests and dynamically render HTML Pages
manifest.yaml file
manifest.yml is added to deploy SAPUI5 application on cloud foundry at SAP Cloud Platform. This file specifies application related information such as name, build pack, command, services etc.
Step2. Install packages using package.json file
Open the Command prompt and navigate to the personslist folder where package.json file is defined.
Run the
npm install command to install the required packages.
Step 3. Deploy application on Cloud Foundry
Go to SAPUI5 application’s local path, then use command
cf push to deploy application on Cloud Foundry at SAP Cloud Platform.
It may fail with status code 400 and error code 210003 as host is already used by someone.
In that case, open the manifest.yaml file of DeploySAPUI5on SAPCF Project
Update the name of application by appending your ID number. Save the manifest.yaml file
Again deploy project to CF by executing
cf push
If everything goes right, you can see following result on the console
if you execute the following url:
https://personslist<ID number>.cfapps.<host>/ui5
you will see the SAPUI5 application output as shown below