Prepare SAP Build Work Zone, Standard Edition Setup for Kyma
- How to add navigation targets and prepare your UI applications
- How to build and push the docker image for HTML5 application deployer
- How to configure your Helm chart for HTML5 application deployment
Prerequisites
- Step 1
In this tutorial, you will use the SAP Build Work Zone, standard edition to access your CAP service and its UI. Additionally, the SAP Build Work Zone, standard edition provides features like personalization, role-based visibility, theming, and more. You can add multiple applications to one launchpad, including subscribed ones and applications from SAP S/4HANA or SAP BTP.
Navigation targets are required to navigate between applications, but also to start the applications from SAP Build Work Zone, standard edition. In the next steps, you add the navigation targets
Risks-display
andMitigations-display
to the application manifest (manifest.json
) file.Log in to complete tutorial - Step 2
Open the file
app/risks/webapp/manifest.json
.Add the external navigation target to the
sap.app
JSON object. You can add it right behind thesourceTemplate
object:
JSONCopy{ ... "sap.app": { "id": "ns.risks", ... "sourceTemplate": { ... }, "crossNavigation": { "inbounds": { "Risks-display": { "signature": { "parameters": {}, "additionalParameters": "allowed" }, "semanticObject": "Risks", "action": "display" } } } } }
Log in to complete tutorial - Step 3
Open the file
app/mitigations/webapp/manifest.json
.Add the external navigation target to the
sap.app
JSON object, but this time withsemanticObject
nameMitigations
. You can add it right after thedataSources
object:
JSONCopy{ ... "sap.app": { "id": "ns.mitigations", ... "dataSources": { ... }, "crossNavigation": { "inbounds": { "Mitigations-display": { "signature": { "parameters": {}, "additionalParameters": "allowed" }, "semanticObject": "Mitigations", "action": "display" } } } } }
Log in to complete tutorial - Step 4
-
Install the SAPUI5 tooling package as a global module in the root folder of your project:
Shell/BashCopynpm install --global @sap/ux-ui5-tooling
-
Install the SAP Fiori application generator package as a global module:
Shell/BashCopynpm install --global @sap/generator-fiori
Log in to complete tutorial -
- Step 5
Since you’re working with a CAP application, there must be an
mta.yaml
deployment descriptor file in your project directory. This file is used during Cloud Foundry deployments to determine what Cloud Foundry apps and service instances should be created. In the context of deploying to Kyma, however, themta.yaml
file will not be used for deployment. Instead, it will only be used by the SAP Fiori generator to add the deployment configurations for the SAP Fiori applicationsRisks
andMitigations
. To create the deployment descriptor, run the following command in your project root folder:Shell/BashCopycds add mta
Log in to complete tutorial - Step 6
Switch to
app/risks
folder:Shell/BashCopycd app/risks
Add deployment configuration:
Shell/BashCopyfiori add deploy-config cf
If the SAP Fiori generator fails, make sure to remove other
.yo-rc.json
files you might have in any of your project’s directories and try again.Enter the following settings:
Destination name ()
:cpapp-srv
Editing the deployment configuration will overwrite existing configuration, are you sure you want to continue? (Y/n)
:y
On Windows, you might get an error when executing this command.
The CDS development kit that we use in this tutorial series includes a batch executable file. Since it’s not a binary, executing it on Windows might return an error similar to this one:
bashCopyError @sap/fiori:deploy-config cf --base ui5.yaml --config ui5-deploy.yaml spawnSync cds ENOENT
The issues is currently being fixed but here a workaround you can use for the time being:
- Open the file
C:\Users\<Your-User>\AppData\Roaming\npm\node_modules\@sap\generator-fiori\generators\deployment-generator\cf\index.js
. - Search for
cwd:this.destinationPath()
. - Add
, shell:true
aftercwd:this.destinationPath()
within the curly brackets. - Save and close the file.
- The
fiori add deploy-config cf
command should run without errors now.
Log in to complete tutorial - Step 7
Switch to the
app/mitigations
folder:Shell/BashCopycd ../../app/mitigations/
Add the deployment configuration:
Shell/BashCopyfiori add deploy-config cf
Enter the following settings:
Destination name ()
:cpapp-srv
Editing the deployment configuration will overwrite existing configuration, are you sure you want to continue? (Y/n)
:y
Log in to complete tutorial - Step 8
Make sure that the value of the
uri
parameter of themainService
object in bothapp/risks/webapp/manifest.json
andapp/mitigations/webapp/manifest.json
does not start with a forward slash (/
):JSONCopy{ "_version": "1.32.0", "sap.app": { ... "dataSources": { "mainService": { "uri": "service/risk/", "type": "OData", "settings": { "odataVersion": "4.0", "localUri": "localService/metadata.xml" } } }, } ... }
This will ensure you don’t get any errors when trying to access the Risks or Mitigations apps later through the SAP Build Work Zone, standard edition.
Log in to complete tutorial - Step 9
Add your SAP Cloud service at the end of
app/risks/webapp/manifest.json
andapp/mitigations/webapp/manifest.json
files:JSONCopy{ "_version": "", ... "sap.fiori": { ... }, "sap.cloud": { "public": true, "service": "cpapp.service" } }
The name of your SAP Cloud service (
cpapp
in this case) should be unique within an SAP BTP region. It is used to identify the resources that belong to one UI in the SAP Build Work Zone, standard edition.Log in to complete tutorial - Step 10
Create a file
app/package.json
for the HTML5 application deployer application and add the following code to it:JSONCopy{ "name": "html5-deployer", "scripts": { "start": "node node_modules/@sap/html5-app-deployer/index.js", "build": "bash build.sh" }, "workspaces": [ "risks", "mitigations" ] }
The
build
script triggers the build of the Fiori applications for deployment in the HTML5 application repository. The two UI applications are referred as sub packages (“workspaces”) which is required for the build.The deployer is run with the
start
script.Add a file
app/build.sh
for the Fiori application build and add the following code to it:Shell/BashCopy#!/bin/bash set -e npm run build:cf --prefix risks npm run build:cf --prefix mitigations rm -rf resources mkdir -p resources mv risks/dist/nsrisks.zip resources mv mitigations/dist/nsmitigations.zip resources if [ "$CNB_STACK_ID" != "" ]; then # Delete directories if running in CNB build to avoid them getting packaged rm -rf risks rm -rf mitigations fi
This script calls the UI5 build for the two SAP Fiori applications and copies the result into the
resources
directory.Navigate back to your project root folder:
Shell/BashCopycd ../..
Add the HTML5 application deployer package
@sap/html5-app-deployer
to theapp/package.json
file:Shell/BashCopynpm install --prefix app @sap/html5-app-deployer
Delete
node_modules
andpackage-lock.json
files withinapp
folder and its subfolders.When switching to the
npm
workspace feature oldpackage-lock.json
andnode_modules
cause problems. Therefore, execute the following command:Shell/BashCopyrm -rf {app,app/risks,app/mitigations}/{node_modules,package-lock.json}
Log in to complete tutorial - Step 11
Set container registry environment variable:
Shell/BashCopyCONTAINER_REGISTRY=<your-container-registry>
Looking for
<your-container-registry>
?Value for
<your-container-registry>
is the same as the docker server URL and the path used for docker login. You can quickly check it by running the following command in your terminal:jsonCopycat ~/.docker/config.json
Build docker image:
Shell/BashCopypack build $CONTAINER_REGISTRY/cpapp-html5-deployer \ --env BP_NODE_RUN_SCRIPTS=build \ --path app \ --buildpack gcr.io/paketo-buildpacks/nodejs \ --builder paketobuildpacks/builder:base
The parameter
--env BP_NODE_RUN_SCRIPTS=build
triggers the build script in theapp/package.json
, which runs the UI5 build for the SAP Fiori applications as it is defined in theapp/build.sh
file. The build result appears in the docker image only. It’s not on your file system.Push docker image:
Shell/BashCopydocker push $CONTAINER_REGISTRY/cpapp-html5-deployer
Log in to complete tutorial - Step 12
Add the HTML5 Application Deployer to your Helm chart:
Shell/BashCopycds add html5-repo
This adds three new sections
html5-apps-deployer
andhtml5_apps_repo_host
anddestinations
to thechart/values.yaml
file and also copies a few additional files in thechart/templates
folder. It deploys your HTML5 applications using thecpapp-html5-deployer
image and creates the required destinations to access the CAP service. TheHTML5Runtime_enabled
option makes the destinations accessible for the SAP Build Work Zone, standard edition.Replace
<your-container-registry>
with your container registry URL in thehtml5-apps-deployer
section of yourchart/values.yaml
file:YAMLCopyhtml5-apps-deployer: cloudService: null backendDestinations: {} image: repository: <your-container-registry>/cpapp-html5-deployer tag: latest
Add the destination and the cloud service to your backend service:
YAMLCopyhtml5-apps-deployer: env: SAP_CLOUD_SERVICE: cpapp.service envFrom: ... ... backendDestinations: cpapp-srv: service: srv
The
backendDestinations
configuration creates a destination with the namecpapp-srv
that points to the URL for your CAP servicesrv
.
With this step we’re reflecting in thevalues.yaml
file the configurations you already did for:- Destination
cpapp-srv
for the Risks application, done inStep 5: Add deployment configuration for the SAP Fiori elements Risks application
. - Destination
cpapp-srv
for the Mitigations application, done inStep 6: Add deployment configuration for the SAPUI5 freestyle Mitigations application
. - Cloud service for both applications, done
Step 7: Add Cloud Service
.
- Destination
Log in to complete tutorial - Step 13
Run the deploy command again:
Shell/BashCopyhelm upgrade cpapp ./chart --install
Which of the following sections are added to the `values.yaml` file after running the `cds add html5-repo` command?
Log in to complete tutorial
- Prepare UI Applications
- Add navigation target for Risks UI
- Add navigation target for Mitigations UI
- Install required UI tools
- Add CAP deployment descriptor
- Add deployment configuration for the SAP Fiori elements Risks application
- Add deployment configuration for the SAPUI5 freestyle Mitigations application
- Adjust data source path to avoid errors
- Add SAP Cloud service
- Create package.json and build script for app deployer
- Build HTML5 application deployer image
- Configure Helm chart for HTML5 application deployment
- Re-deploy your application