Deploy the SAPUI5 Frontend in SAP BTP, Kyma Runtime
Develop and deploy the SAPUI5 frontend app in SAP BTP, Kyma runtime.
Overview
You will learn
- How to configure and build SAPUI5 Docker image
- How to deploy the SAPUI5 Docker image to SAP BTP, Kyma runtime
Prerequisites
Prerequisites
- Docker installed with a valid public account
- kubectl configured to kubeconfig downloaded from SAP BTP, Kyma runtime
- Git
- Node.js
- UI5 Tooling
- Deploy a Go MSSQL API Endpoint in SAP BTP, Kyma Runtime tutorial completed
Steps
Go to kyma-runtime-extension-samples. This repository contains a collection of Kyma sample applications which will be used during the tutorial.
Use the Code button to choose one of the options to download the code locally, or simply run the following command in your CLI at your desired folder location:
Shell/Bashgit clone https://github.com/SAP-samples/kyma-runtime-extension-samples
Open the
frontend-ui5-mssqldirectory in your desired editor.Explore the content of the sample.
You can find many directories that relate to the UI5 application.
The
dockerdirectory contains the Dockerfile used to generate the Docker image. The image is built in two stages to create a small image. In the first stage, aNodeJSimage is used, which copies the related content of the project into the image and builds the application. The built application is then copied into annginximage with the default setup exposing the application on port 80.Within the
k8sdirectory, you can find the Kubernetes/Kyma resources you will apply to your SAP BTP, Kyma runtime.
Within the
frontend-ui5-mssqldirectory, run the following command using your CLI to install the application dependencies:Shell/Bashnpm installRun the following command to get the SAP BTP, Kyma runtime cluster domain:
Shellkubectl get gateway -n kyma-system kyma-gateway \ -o jsonpath='{.spec.servers[0].hosts[0]}'Result should look like this:
Shell*.<xyz123>.kyma.ondemand.comWithin the project, open the
webapp/config.jsonfile and adjustAPI_URLto match the cluster domain.Text/Javascript{ "API_URL": "https://api-mssql-go.*******.kyma.ondemand.com" }To start the application, run the following command, which should automatically load the application in your browser.
Shell/Bashnpm run-script startPressing
control-cwill stop the running application.After you tested the application locally, go to the
api-mssql-go/k8sdirectory, and openapirule.yaml.Remove the
exact: http://localhost:8080line, and apply the APIRule.Shell/Bashkubectl -n dev apply -f ./k8s/apirule.yaml
Run the following commands from the frontend-ui5-mssql directory using your CLI. Make sure to replace the value of <your-docker-id> with your Docker account ID.
If you’re using any device with a non-x86 processor (e.g. MacBook M1/M2) you need to instruct Docker to use x86 images by setting the DOCKER_DEFAULT_PLATFORM environment variable using the command
export DOCKER_DEFAULT_PLATFORM=linux/amd64. Check Environment variables for more information.
To build the Docker image, run this command:
Shell/Bashdocker build -t <your-docker-id>/fe-ui5-mssql -f docker/Dockerfile .To push the Docker image to your Docker repository, run this command:
Shell/Bashdocker push <your-docker-id>/fe-ui5-mssql
You can find the resource definitions in the k8s folder. If you performed any changes in the configuration, these files may also need to be updated. The folder contains the following files that are relevant to this tutorial:
apirule.yaml: defines the API endpoint which exposes the application to the Internet. This endpoint does not define any authentication access strategy and should be disabled when not in use.configmap.yaml: definesAPI_URL, which represents the endpoint used for the orders API. It must be adjusted to reflect the domain of SAP BTP, Kyma runtime.deployment.yaml: defines the Deployment definition for the SAPUI5 application as well as a service used for communication. This definition referencesconfigmap.yamlby name. It is used to overwritewebapp/config.jsonof the application.
Within the project, open the
k8s/configmap.yamlfile and adjustAPI_URLto match the cluster domain:Codekind: ConfigMap apiVersion: v1 metadata: name: fe-ui5-mssql labels: app: fe-ui5-mssql data: config.json: |- { "API_URL": "https://api-mssql-go.*******.kyma.ondemand.com" }Apply the ConfigMap:
Shell/Bashkubectl -n dev apply -f ./k8s/configmap.yamlIn
deployment.yaml, adjust the value ofspec.template.spec.containers.imageto use your Docker image. Apply the Deployment:Shell/Bashkubectl -n dev apply -f ./k8s/deployment.yamlApply the APIRule:
Shell/Bashkubectl -n dev apply -f ./k8s/apirule.yaml
To access the application, you can use the APIRule created in the previous step.
Open Kyma dashboard.
From the menu, choose Namespaces, and go to the
devnamespace.Choose Discovery and Network > API Rules.
Choose the Host entry for the fe-ui5-mssql APIRule to open the application in the browser. This should be similar to:
https://fe-ui5-mssql.*******.kyma.ondemand.com
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.