Prepare Multi-Tenant Applications for Deployment with CAP Operator
This tutorial shows you how to prepare your multi-tenant application for deployment in SAP BTP, Kyma runtime using the CAP Operator.
Overview
You will learn
- How to build container images for your multi-tenant application and push them to a container registry.
Prerequisites
Prerequisites
- You’ve configured the respective entitlements, enabled the Kyma runtime in your SAP BTP subaccount, and created an SAP HANA Cloud service instance in the SAP BTP cockpit. Follow the steps in the Setting Up SAP BTP and Kyma Runtime for Deployment tutorial that is part of the Application Lifecycle Management using CAP Operator tutorial group.
- You’ve installed all the required tools. Follow the steps in the Install Tools for Deployment tutorial that is part of the Application Lifecycle Management using CAP Operator tutorial group.
Steps
Clone the application from the Incident Management Application GitHub Repository. For e.g. using:
git clone https://github.com/cap-js/incidents-app.git -b cap-operator-tutorialsThis is a multi-tenant SAP Cloud Application Programming Model (CAP) application. It utilizes the application router for routing, SAP Authorization and Trust Management service (XSUAA), and SAP HANA Cloud as the database. The front end is built with SAP Fiori and deployed to the HTML5 Application Repository.
Open a command-line window in the folder where your application holds incidents-app and run the following command to open the project in Visual Studio (VS) Code:
code .Make sure you’re logged in to your container registry. In case if you don’t have access to a container registry, you can make use of the Docker Registry Community Module from Kyma.
If you’re using a device with a non-x86 processor (for example, 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 the environment variables for more information.
Make sure to replace
<your-container-registry>with the link to your container registry and keep in mind that<image version>is a string.
Looking for your Docker server URL?
The Docker server URL is the same as the path used for Docker login, so you can quickly check it by running the following command in your terminal:
JSONcat ~/.docker/config.json
In case you’re using Docker Hub as your container registry, replace the placeholder
<your-container-registry>with your Docker Hub user ID.
Build the CAP Node.js and the MTXS sidecar image
In VS Code, choose Terminal โ New Terminal and run the following command:
Shellnpm installThis command installs the required dependencies and updates the package-lock.json file of your project.
Create the productive CAP build for your application:
Shellnpx cds build --productionThe CAP build writes to the gen/srv folder.
Build the CAP Node.js image:
Shellpack build <your-container-registry>/incident-management-srv:<image-version> \ --path gen/srv \ --builder paketobuildpacks/builder-jammy-base \ --publishThe pack CLI builds the image that contains the build result in the gen/srv folder and the required npm packages by using the Cloud Native Buildpack for Node.js provided by Paketo.
Build the MTXS sidecar image:
Shellpack build <your-container-registry>/incident-management-mtxs-sidecar:<image-version> \ --path gen/mtx/sidecar \ --builder paketobuildpacks/builder-jammy-base \ --publishIMPORTANT: The project.toml file in the gen/mtx/sidecar folder is copied automatically from the mtxs/sidecar folder during the build. This file exposes the node process inside the container so that CAP Operator can trigger tenant operations using the MTXS CLIs.
Build the application router image
In the VS Code terminal, navigate to the app/router folder and run the following command:
Shellnpm installIn the VS Code terminal, navigate back to the root folder of your project:
Shellcd ../..Build the application router image:
Shellpack build <your-container-registry>/incident-management-approuter:<image-version> \ --path app/router \ --buildpack paketo-buildpacks/nodejs \ --builder paketobuildpacks/builder-jammy-base \ --env BP_NODE_RUN_SCRIPTS="" \ --publish
Build the HTML5 deployer image
In the VS Code terminal, navigate to the ui-resources folder and run the following command:
Shellnpm install && npm run packageThis command builds and copies the archive nsincidents.zip inside the ui-resources/resources folder.
In the VS Code terminal, navigate back to the root folder of your project:
Shellcd ..Build the UI deployer image:
Shellpack build <your-container-registry>/incident-management-html5-deployer:<image-version> \ --path ui-resources \ --builder paketobuildpacks/builder-jammy-base \ --publish
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.