Skip to content

Latest commit

 

History

History
90 lines (60 loc) · 2.29 KB

production_guide.md

File metadata and controls

90 lines (60 loc) · 2.29 KB

Production Deployment Guide for CAP Applications Using Attachments

In this guide, we use the Tiny-Sample reference sample app as the base application to add the Attachments type to the CDS model.

Prerequisite

  • You need to prepare the following services for Attachments:
  1. Entitlement for SAP Object Store with standard service plan for your subaccount
  2. Entitlement for Malware scanning service with clamav plan for your subaccount

Setup

  • The following section is where we setup one sample application for development:
mkdir tiny-sample
cd tiny-sample
cds init
cds add tiny-sample
npm i
  • To enable attachments, simply adding this self-configuring plugin package into our project:
npm add @cap-js/attachments

Use Attachments

  • To use Attachments, simply add an element referring to the pre-defined Attachments type as follows:
using {Attachments} from '@cap-js/attachments';

entity Books {
  key ID          : Integer;
    //... 
    attachments : Composition of many Attachments;
}

Test Locally

cds watch

Prepare for Production

  • While we used SQLite as a low-cost stand-in during development, we're going to use a managed SAP HANA database for production:
cds add hana --for production
  • Configure your app for XSUAA-based authentication:
cds add xsuaa --for production
  • We'll be using the Cloud MTA Build Tool to execute the deployment on Cloud Foundry:
cds add mta
  • You can refer to the mta.yaml file of this repo for your reference.

  • Run cds build to generate additional deployment artifacts and prepare everything for production in a local ./gen folder as a staging area.

cds build --production
  • Now, we use the mbt build tool to assemble everything into a single mta.tar archive:
mbt build -t gen --mtar mta.tar

Deploy to Cloud Foundry

  • Finally, we can deploy the generated archive to Cloud Foundry:
cf deploy gen/mta.tar