The example will deployment of HTML5 Application Content via MTA. It demonstrates how to deploy content using directly HTML5 Application Repository service
The following MTA modeling in development (mta.yaml
) or deployment (mtad.yaml
) descriptors utilizes the feature:
...
modules:
- name: content-module
type: com.sap.application.content
requires:
- name: content-consuming-service-instance
parameters:
content-target: true
resources:
- name: content-consuming-service-instance
type: org.cloudfoundry.existing-service
The module, representing the content, is defined by type: com.sap.application.content
. The service(s) to which content is deployed are listed in the module’s requires
list and are depicted with a parameter content-target: true
.
The required resource should be of type corresponding to a Cloud Foundry service instance, be it org.cloudfoundry.existing-service
, org.cloudfoundry.managed-service
, or any type extending managed-service.
While the example above would create a service key in order to take the service credentials needed to deploy the content to the target service, it is also possible to model the MTA to use an already existing service key as shown in Generic Application Content Deployment With Existing Key.
In the current directory you’ll find example MTA. The zip archive contains three other archives of HTML5 Application content.
-
deployment descriptor: mtad.yaml
Note
|
Though the example showcases HTML5 Application content, this generic modeling and mechanism works with a variety of SCP service contents. |
The example demonstrates 2 different approaches, leading to the same result.
This approach uses deployment descriptor mtad.yaml
and existing app binary.
In the current directory, run cf deploy
. This will automatically assemble an MTA archive and deploy it:
$ cf deploy ./
Deploying multi-target app archive */mta-examples/ui5MTA.mtar in org ******** / space ******** as ********...
Uploading 1 files...
*/mta-examples/ui5MTA.mtar
OK
Deploying in org "********" and space "********"
Detected MTA schema version: "3"
No deployed MTA detected - this is initial deployment
Detected new MTA version: "0.0.1"
Processing service "ui5-repo-service-instance"...
Creating service "ui5-repo-service-instance" from MTA resource "ui5-repo-service-instance"...
Creating service key "ui5module-ui5-repo-service-instance-credentials" for service "ui5-repo-service-instance"...
Uploading content module "ui5module" in target service "ui5-repo-service-instance"...
Deploying content module "ui5module" in target service "ui5-repo-service-instance"...
Skipping deletion of services, because the command line option "--delete-services" is not specified.
Process finished.
This approach uses deployment descriptor mtad.yaml
and Cloud MTA Build Tool uses it to package the ready binaries into an MTAR archive.
The newly generated MTAR is then deployed.
First use mbt assemble
to create the *.mtar archive and than deploy it with cf deploy
:
$ mbt assemble
INFO assembling the MTA project...
INFO copying the MTA content...
INFO generating the metadata...
INFO generating the MTA archive...
INFO the MTA archive generated at: /mta_examples/content-deployment/mta_archives/ui5MTA_0.0.1.mtar
INFO cleaning temporary files...
$ cf deploy mta_archives/ui5MTA_0.0.1.mtar
...
If you maintain you project’s sources in an MTA format and have the mta.yaml
descriptor where content module is modeled as described above, you can create an MTA archive for this project using a regular build command of the MTA build tool of your choice. Since we recommend the new Cloud MTA Build Tool for buiding MTA projects, the command in our example is mbt build
.
Note
|
The example is incomplete. For more information check the official documentation |
If you have several HTML5 modules in your project and would like to deploy their content into a HTML5 repository, you need to adjust the build process as follows:
-
The build scripts of each HTML5 module should produce a
zip
archive. For example, if you are using a Grunt build based on@sap/grunt-sapui5-bestpractice-build
:
In package.json: add dependency to the grunt-zip
package
...
"devDependencies": {
...
"grunt-zip": "latest"
},
...
In Gruntfile.js: add definition of the grunt-zip
task and add the zip
task as the last step of the default
task.
Pay attention that the name of the result zip file should be unique cross HTML5 modules of the project. You can achieve it by using the format: <modulename>-content.zip
...
grunt.registerTask("default", [
"clean",
"lint",
"build",
"zip"
]);
...
// Define a zip task
grunt.loadNpmTasks('grunt-zip');
grunt.config.merge({
zip: {
'using-cwd': {
cwd: 'dist/',
src: ['dist/*'],
dest: 'dist/<modulename>-content.zip'
}
}
...
-
In mta.yaml file, build parameters of each HTML5 should include
supported-platforms
anddist
parameters with the values below:
- name: ui1
type: html5
path: ui1
build-parameters:
builder: grunt
supported-platforms: []
build-result: dist
supported-platforms: []
indicates that this module will not appear in the resulting deployment descriptor. Its content will be deployed via a module where we collect content from all HTML5 modules.
build-result: dist
instructs the MBT where to look for build result of this module.
-
The mta.yaml file should contain a module that is defined as a content one. Also you will need to configure its build parameters to copy content from all HTML5 modules (
zip
archive created during their build) into its internal folder (e.g.resources
as in the example below). The content of this folder will be packaged as build result into the resulting MTA archive and this is the content (zip
ofzips
) that will be deployed to the HTML5 repository.
- name: mta_ui1_ui_deployer
type: com.sap.application.content # Generic type for the content module
path: mta_ui1_ui_deployer
requires:
- name: mta_ui1_html5_repo_host # HTML5 repository service
parameters:
content-target: true
build-parameters:
build-result: resources # specify folder to package
requires:
- name: ui1
artifacts:
- 'ui1-content.zip'
target-path: resources/
- name: ui2
artifacts:
- 'ui2-content.zip'
target-path: resources/
-
Now you can build your project:
mbt build
and deploy to the target environmentcf deploy <path to the mtar>