if(재능이 없으면 시간으로 극복하라){return 성공;}

SAP BTP - MTA(Multi-Target Application)를 사용하여 어플리케이션을 구성하고 배포해보자.

명령어를 통해 mbt를 설치해보자

npm install --global mbt

버전을 확인해보면, 정상적으로 잘 설치되었다. image

현재 환경은 윈도우이기 때문에 make tool을 설치. https://gnuwin32.sourceforge.net/packages/make.htm 에 접속하여 image

위 표시해 놓은 부분 다운로드

이후 Cloud Foundry End Point를 설정하고 login

cf api https://api.cf.us10-001.hana.ondemand.com

로그인

cf login

명령어를 통해 multiapps plugin 설치

cf install-plugin multiapps

plugin 확인

cf plugins

image

기존에 사용하던 cpapp의 pacakge.json을 수정 image

cpapp의 루트 경로에서 명령어를 통해 mta 추가

cds add mta

image

mta.yaml 파일 생성됨 image

배포시에 csv를 제외하기 위해 mta.yaml 파일 수정 image

권한을 추가 하기 위해 mta.yaml 파일 수정 image

이후 빌드 테스트

mbt build -t ./

오류 발생 make에 대한 PATH를 안잡아줬나 보다. image

환경변수 추가 image

다시 빌드를 해보니 빌드 파일 제대로 생성 되었음 image

만들어진 파일을 Cloud Foundry에 배포해보자.

cf deploy cpapp_1.0.0.mtar

Service plan application not found. 이라면서 제대로 배포가 되지 않음.

[2024-04-17 11:31:28]  INFO Cloud MTA Build Tool version 1.2.27
[2024-04-17 11:31:28]  INFO generating the "Makefile_20240417113128.mta" file...
[2024-04-17 11:31:28]  INFO done
[2024-04-17 11:31:28]  INFO executing the "make -f Makefile_20240417113128.mta p=cf mtar= strict=true mode= t=\"./\"" command...
[2024-04-17 11:31:28]  INFO validating the MTA project
[2024-04-17 11:31:28]  INFO running the "before-all" build...
[2024-04-17 11:31:28]  INFO executing the "npm install --production" command...
npm WARN config production Use `--omit=dev` instead.
......npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'cpapp@1.0.0',
npm WARN EBADENGINE   required: { node: '^18' },
npm WARN EBADENGINE   current: { node: 'v20.10.0', npm: '10.2.3' }
npm WARN EBADENGINE }
.
added 27 packages, and audited 105 packages in 6s

14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[2024-04-17 11:31:35]  INFO executing the "npx -p @sap/cds-dk cds build --production" command...
..npm WARN exec The following package was not found and will be installed: @sap/cds-dk@7.8.2
...................building project [C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp], clean [true]
cds-dk [7.8.2], cds [7.8.1], compiler [4.8.0], home [C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp\node_modules\@sap\cds]

{
  build: {
    target: 'gen',
    tasks: [
      { for: 'hana', src: 'db', options: { model: ['db', 'srv', 'app'] }},
      { for: 'nodejs', src: 'srv', options: { model: ['db', 'srv', 'app'] }}
    ]
  }
}

..done > wrote output to:
   gen\db\package.json
   gen\db\src\.hdiconfig
   gen\db\src\gen\.hdiconfig
   gen\db\src\gen\.hdinamespace
   gen\db\src\gen\DRAFT.DraftAdministrativeData.hdbtable
   gen\db\src\gen\RiskService.DraftAdministrativeData.hdbview
   gen\db\src\gen\RiskService.Mitigations.hdbview
   gen\db\src\gen\RiskService.Mitigations_drafts.hdbtable
   gen\db\src\gen\RiskService.Risks.hdbview
   gen\db\src\gen\RiskService.Risks_drafts.hdbtable
   gen\db\src\gen\data\sap.ui.riskmanagement-Mitigations.csv
   gen\db\src\gen\data\sap.ui.riskmanagement-Mitigations.hdbtabledata
   gen\db\src\gen\data\sap.ui.riskmanagement-Risks.csv
   gen\db\src\gen\data\sap.ui.riskmanagement-Risks.hdbtabledata
   gen\db\src\gen\sap.ui.riskmanagement.Mitigations.hdbtable
   gen\db\src\gen\sap.ui.riskmanagement.Risks.hdbtable
   gen\db\undeploy.json
   gen\srv\.cdsrc.json
   gen\srv\package-lock.json
   gen\srv\package.json
   gen\srv\srv\_i18n\i18n.json
   gen\srv\srv\csn.json
   gen\srv\srv\odata\v4\RiskService.xml
   gen\srv\srv\risk-service.js

build completed in 2211 ms

[2024-04-17 11:31:59]  INFO executing the "npx rimraf gen/db/src/gen/data" command...
...npm WARN exec The following package was not found and will be installed: rimraf@5.0.5
..[2024-04-17 11:32:04]  INFO validating the MTA project
[2024-04-17 11:32:05]  INFO building the "cpapp-srv" module...
[2024-04-17 11:32:05]  INFO executing the "npm install --production" command...
npm WARN config production Use `--omit=dev` instead.
.npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'cpapp@1.0.0',
npm WARN EBADENGINE   required: { node: '^18' },
npm WARN EBADENGINE   current: { node: 'v20.10.0', npm: '10.2.3' }
npm WARN EBADENGINE }
.
added 104 packages, and audited 105 packages in 2s

14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
.[2024-04-17 11:32:08]  INFO the build results of the "cpapp-srv" module will be packaged and saved in the ".cpapp_mta_build_tmp\cpapp-srv" folder
[2024-04-17 11:32:29]  INFO finished building the "cpapp-srv" module
[2024-04-17 11:32:29]  INFO building the "cpapp-db-deployer" module...
[2024-04-17 11:32:29]  INFO executing the "npm install --production" command...
npm WARN config production Use `--omit=dev` instead.
...
added 31 packages, and audited 32 packages in 2s

found 0 vulnerabilities
[2024-04-17 11:32:32]  INFO the build results of the "cpapp-db-deployer" module will be packaged and saved in the ".cpapp_mta_build_tmp\cpapp-db-deployer" folder
[2024-04-17 11:32:48]  INFO finished building the "cpapp-db-deployer" module
[2024-04-17 11:32:48]  INFO running the "after-all" build...
[2024-04-17 11:32:48]  INFO generating the metadata...
[2024-04-17 11:32:48]  INFO generating the "C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp\.cpapp_mta_build_tmp\META-INF\mtad.yaml" file...
[2024-04-17 11:32:48]  INFO generating the MTA archive...
[2024-04-17 11:32:49]  INFO the MTA archive generated at: cpapp_1.0.0.mtar
[2024-04-17 11:32:49]  INFO cleaning temporary files...

C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp>cf services
Getting service instances in org 6fc6fbb5trial_account-test-bczzg397 / space dev as nuruhee@bjsystems.kr...

name    offering           plan   bound apps   last operation     broker                                                     upgrade available
cpapp   hana-cloud-trial   hana                update succeeded   sm-hana-cloud-trial-1ce8c293-a0f4-40b1-a52e-a70f7ac4a749   no

C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp>cf deploy cpapp_1.0.0.mtar
Deploying multi-target app archive cpapp_1.0.0.mtar in org 6fc6fbb5trial_account-test-bczzg397 / space dev as nuruhee@bjsystems.kr...

Uploading 1 files...
  C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp\cpapp_1.0.0.mtar
 2m15s  66.02 MiB / 66.02 MiB [====================================================================================================================================================================================================================] 100.00% 2m15s
OK
Operation ID: c6806867-fc63-11ee-8839-eeee0a9eafcf
Deploying in org "6fc6fbb5trial_account-test-bczzg397" and space "dev"
Detected MTA schema version: "3"
No deployed MTA detected - this is initial deployment of MTA with ID "cpapp"
Detected new MTA version: "1.0.0"
Processing service "cpapp-uaa"...
Setting service "cpapp-uaa" parameters from "xs-security.json"
Processing service "cpapp-db"...
Creating service "cpapp-db" from MTA resource "cpapp-db"...
Creating service "cpapp-uaa" from MTA resource "cpapp-uaa"...
Service operation failed: Controller operation failed: 404 Not Found: Error creating or updating service instance: Could not create service "cpapp-uaa" : Service plan application not found.
Proceeding with automatic retry... (3 of 3 attempts left)
Creating service "cpapp-uaa" from MTA resource "cpapp-uaa"...
Service operation failed: Controller operation failed: 404 Not Found: Error creating or updating service instance: Could not create service "cpapp-uaa" : Service plan application not found.
Proceeding with automatic retry... (2 of 3 attempts left)
Creating service "cpapp-uaa" from MTA resource "cpapp-uaa"...
Service operation failed: Controller operation failed: 404 Not Found: Error creating or updating service instance: Could not create service "cpapp-uaa" : Service plan application not found.
Proceeding with automatic retry... (1 of 3 attempts left)
0 of 1 done, (1 creating)
Creating service "cpapp-uaa" from MTA resource "cpapp-uaa"...
Service operation failed: Controller operation failed: 404 Not Found: Error creating or updating service instance: Could not create service "cpapp-uaa" : Service plan application not found.
Process failed.
Use "cf deploy -i c6806867-fc63-11ee-8839-eeee0a9eafcf -a abort" to abort the process.
Use "cf deploy -i c6806867-fc63-11ee-8839-eeee0a9eafcf -a retry" to retry the process.
Use "cf dmol -i c6806867-fc63-11ee-8839-eeee0a9eafcf" to download the logs of the process.

C:\Users\nuruh\OneDrive\바탕 화면\project\tutorial\cpapp>cf services
Getting service instances in org 6fc6fbb5trial_account-test-bczzg397 / space dev as nuruhee@bjsystems.kr...

name       offering           plan         bound apps   last operation     broker                                                     upgrade available
cpapp      hana-cloud-trial   hana                      update succeeded   sm-hana-cloud-trial-1ce8c293-a0f4-40b1-a52e-a70f7ac4a749   no
cpapp-db   hana               hdi-shared                create succeeded   sm-hana-broker-d9567008-60db-4ec6-b75e-bbabaab4ab13        no

인타이틀먼트에 권환 및 트러스트 관리 서비스가 application의 플랜으로 구독이 되어있어야 하는데 되어있지 않았음. 그래서 추가해주니 정상적으로 동작.

image

image

명령어를 통해 실행중인 서비스를 확인해보니

cf apps

image

다 멈춰져 있다.

mtar 파일로 build를 진행할 때 로컬의 node버전이 20이라서 Warning이 떴었는데.. 일단 다시 빌드를 하고 배포를 해보니 정상적으로 실행되는 것을 확인하였다.

image image