SB3: Deploy App (Multi-Target)

Task: Deploy Application (Multi Target)

Create a new file called mta.yaml and adjust <userID> / path. This will not only create and deploy the CF app itself, but also spin up the S3 bucket automatically, so that both lifecycles are connected.

_schema-version: 3.3.0
ID: <userID>-mta-cf-sample
version: 1.0.0
parameters:
  enable-parallel-deployments: true
modules:
  - name: mainapp
    type: java.tomee
    path: application/target/<userID>-mta-cf-sample-application.war
    parameters:
      memory: 1024M
      disk-quota: 1024M
      random-route: true
    properties: 
      TARGET_RUNTIME: tomee7
      SET_LOGGING_LEVEL: '{ROOT: INFO, com.sap.cloud.sdk: INFO}'
      JBP_CONFIG_SAPJVM_MEMORY_SIZES: 'metaspace:128m..'
    provides:
      - name: main
        properties:
          url: ${default-url}
    requires:
      - name: s3-storage
resources:
  - name: s3-storage
    type: org.cloudfoundry.managed-service
    parameters:
      service: s3
      service-plan: production

Next, go add the CF plugin for Multi Target Applications:

$ cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
$ cf install-plugin multiapps

Install also the MTA Build Tool

For Linux execute the following, other platforms see here.

$ wget https://github.com/SAP/cloud-mta-build-tool/releases/download/v1.0.12/cloud-mta-build-tool_1.0.12_Linux_amd64.tar.gz
$ tar xvzf cloud-mta-build-tool_1.0.12_Linux_amd64.tar.gz
$ sudo cp mbt /usr/local/bin/

Create MTA package

$ mbt build

Node

Deploy

$ cf deploy mta_archives/<userID>-mta-cf-sample_1.0.0.mtar

Node

Test the application again by uploading a file to the respective S3 bucket

Node

Undeploy as follows. If you like to keep the bucket, simply remove –delete-services

$ cf undeploy <userID>-mta-cf-sample --delete-services