Add Deployment Files for Kyma
mainTo prepare the project for Kyma deployment, use the CAP CLI to add the necessary Helm chart and HTML5 repository features:
cds add helm
cds add html5-reporepository·main·Indexed 42 days ago
https://github.com/sap-samples/cap-sflightA sample application for the travel reference scenario built using the SAP Cloud Application Programming Model (CAP) and SAP Fiori Elements. It demonstrates SAP Fiori annotations and provides implementation examples for both Node.js and Java stacks, including deployment options for SAP BTP and Kyma Runtime.
To prepare the project for Kyma deployment, use the CAP CLI to add the necessary Helm chart and HTML5 repository features:
cds add helm
cds add html5-repoTo start the OPA (Object Page Automation) integration tests, open the following URL in your browser after the application is running locally:
http://localhost:4004/travel_processor/webapp/test/integration/Opa.qunit.html
For further details on testing, refer to the SAP UI5 API documentation.
http://localhost:4004/travel_processor/webapp/test/integration/Opa.qunit.htmlTo deploy a Node.js backend, ensure you set CDS_ENV=node during the build process.
# Build the application
CDS_ENV=node cds build --production
# Build database deployer image
pack build $YOUR_CONTAINER_REGISTRY/sflight-hana-deployer \
--path gen/db \
--buildpack gcr.io/paketo-buildpacks/nodejs \
--builder paketobuildpacks/builder-jammy-base \
--env BP_NODE_RUN_SCRIPTS=""
# Build CAP service image
pack build $YOUR_CONTAINER_REGISTRY/sflight-srv \
--path "gen/srv" \
--buildpack gcr.io/paketo-buildpacks/nodejs \
--builder paketobuildpacks/builder-jammy-base \
--env BP_NODE_RUN_SCRIPTS=""bash .github/deployment/kyma/scripts/build-ui-image.shdocker push $YOUR_CONTAINER_REGISTRY/sflight-hana-deployer
docker push $YOUR_CONTAINER_REGISTRY/sflight-srv
docker push $YOUR_CONTAINER_REGISTRY/sflight-html5-deployer# Node.js Build Example
CDS_ENV=node cds build --production
pack build $YOUR_CONTAINER_REGISTRY/sflight-srv \
--path "gen/srv" \
--buildpack gcr.io/paketo-buildpacks/nodejs \
--builder paketobuildpacks/builder-jammy-base \
--env BP_NODE_RUN_SCRIPTS=""Before deploying the CAP SFLIGHT application to SAP BTP Kyma Runtime, ensure you have the following resources and tools configured:
hdi-shared (HANA HDI Services & Container plan).standard (Build Work Zone plan).kubectl, kubectl-oidc_login, pack, docker, helm, cf.kubectl), Cloud Foundry space (via cf), and your Container Registry (via docker login).@sap/cds-dk version >= 6.6.0.This project uses an MTA (Multi-Target Application) configuration for deployment to SAP BTP.
mta.yaml.mta-java.yaml to mta.yaml before building.Ensure you have the Cloud Foundry CLI, the MultiApps plugin, and the Cloud MTA Build Tool installed:
# Install MultiApps plugin
cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
cf install-plugin multiapps
# Install Cloud MTA Build Tool
npm install -g mbtExecute the build from the project root, then deploy the resulting archive using the CF CLI:
# Build the project
mbt build
# Deploy the archive (replace version as needed)
cf deploy mta_archives/capire.sflight_1.0.0.mtarmbt build
cf deploy mta_archives/capire.sflight_1.0.0.mtarTo deploy a Java backend, follow these steps:
# Build the application
cds build --production
# Build database deployer image
pack build $YOUR_CONTAINER_REGISTRY/sflight-hana-deployer \
--path gen/db \
--buildpack gcr.io/paketo-buildpacks/nodejs \
--builder paketobuildpacks/builder-jammy-base \
--env BP_NODE_RUN_SCRIPTS=""
# Build CAP service image
mvn package
pack build $YOUR_CONTAINER_REGISTRY/sflight-srv \
--path srv/target/*-exec.jar \
--buildpack gcr.io/paketo-buildpacks/sap-machine \
--buildpack gcr.io/paketo-buildpacks/java \
--builder paketobuildpacks/builder-jammy-base \
--env SPRING_PROFILES_ACTIVE=cloud \
--env BP_JVM_VERSION=17bash .github/deployment/kyma/scripts/build-ui-image.shdocker push $YOUR_CONTAINER_REGISTRY/sflight-hana-deployer
docker push $YOUR_CONTAINER_REGISTRY/sflight-srv
docker push $YOUR_CONTAINER_REGISTRY/sflight-html5-deployer# Java Build Example
cds build --production
mvn package
pack build $YOUR_CONTAINER_REGISTRY/sflight-srv \
--path srv/target/*-exec.jar \
--buildpack gcr.io/paketo-buildpacks/sap-machine \
--buildpack gcr.io/paketo-buildpacks/java \
--builder paketobuildpacks/builder-jammy-base \
--env SPRING_PROFILES_ACTIVE=cloud \
--env BP_JVM_VERSION=17After deployment, follow these steps to access the user interface:
sflight.admin of the sflight.tXYZ application to the sflight role collection.sflight role collection.sapfecaptravel.To run the application locally using the Java stack, follow these steps in the project root:
npm cinpm run build:ui (Note: You must run this after every UI change as there is no watch mode for Fiori UI).mvn spring-boot:runOnce running, you can access the SAP Fiori apps at:
http://localhost:4004/travel_processor/dist/index.htmlhttp://localhost:4004/travel_analytics/dist/index.htmlDefault Login Credentials:
amynpm ci
npm run build:ui
mvn spring-boot:runTo develop locally while connected to a remote SAP HANA Cloud instance:
cds deploy --to hana to create/update the HDI container.cloud Spring profile. This ensures the app connects to the HDI container using credentials stored in your local default-env.json.Execution Commands:
mvn spring-boot:run -Dspring-boot.run.profiles=cloudspring.profiles.active=cloudcds deploy --to hana
# Using Maven
mvn spring-boot:run -Dspring-boot.run.profiles=cloudFollow these steps to configure your Kubernetes environment for deployment:
Export your kubeconfig and set the target namespace:
set KUBECONFIG=~/.kube/cap-kyma-app-config
kubectl config set-context --current --namespace=<<NAMESPACE>>Run the provided script to create a container-registry secret containing your registry credentials:
bash .github/deployment/kyma/scripts/create-container-registry-secret.shNote: The Docker Server must be the fully-qualified hostname of your registry.
If using a BTP Trial account, you must create an HDI container and a corresponding Kubernetes secret. For production or free tier accounts, you can skip this by mapping your Kyma namespace to your HANA Cloud instance directly.
To create the secret for a trial account:
bash .github/deployment/kyma/scripts/create-db-secret.sh sflight-dbThis creates an HDI container named sflight-db in your Cloud Foundry space and a Kubernetes secret named sflight-db in your namespace.
set KUBECONFIG=~/.kube/cap-kyma-app-config
kubectl config set-context --current --namespace=<<NAMESPACE>>
bash .github/deployment/kyma/scripts/create-container-registry-secret.sh
bash .github/deployment/kyma/scripts/create-db-secret.sh sflight-dbOnce images are pushed to your registry, deploy the application using Helm. This command also injects the XSUAA security configuration:
helm install sflight ./chart --set-file xsuaa.jsonParameters=xs-security.jsonTo run the application locally using the Node.js stack, ensure you have the @sap/cds-dk development kit installed. Follow these steps in the project root:
npm cicds watchOnce running, you can access the SAP Fiori apps at:
http://localhost:4004/sap.fe.cap.travel/index.htmlhttp://localhost:4004/sap.fe.cap.travel_analytics/index.html# Prerequisite
npm i -g @sap/cds-dk
# Run locally
npm ci
cds watch