This example shows how to model a CF application running a docker image, as an MTA. Cloud foundry container runtime brings the capability to download docker images from a registry as dockerhub and to spin up containers from such. Those containers are managed just as regular cf apps. Documentated in the CF docs: Deploying an App with Docker
The actual image getting deployed is of a cf sample app written in go: https://github.com/cloudfoundry-samples/test-app.git
The example demostrate 2 different approaches that lead to the same result.
That approach uses deployment descritpr mtad.yaml
:
$ cf deploy ./
Deploying multi-target app archive /Users/******/dev/repos/ds/cf-mta-examples/cf-app-docker/a.docker.cf.app.mtar in org ****** / space ****** as ******...
...
Deploying in org "deploy-service" and space "******"
Detected MTA schema version: "3"
Detected deployed MTA with ID "a.docker.cf.app" and version "0.0.0"
Detected new MTA version: "0.0.0"
Deployed MTA version: "0.0.0"
Adding domain "my-mta-managed-app.cfapps.sap.hana.ondemand.com"...
Updating application "my-mta-managed-app"...
Uploading application "my-mta-managed-app"...
Stopping application "my-mta-managed-app"...
Starting application "my-mta-managed-app"...
Application "my-mta-managed-app" started and available at "my.my-mta-managed-app.cfapps.sap.hana.ondemand.com"
...
Process finished.
To generate the MTA archive based on the design time MTA decriptor mta.yaml use the Cloud MTA Build tool 'build' command that creates the MTAR from the project sources:
mbt build
To generate the MTA archive based on the deployment time MTA decriptor mtad.yaml use the Cloud MTA Build tool 'assemble' command that assembles the MTAR from already built binaries:
mbt assemble
Then the newly generated MTAR is used for deployment.
cf deploy mta_archives/a.docker.cf.app_0.0.0.mtar ;
$ cf mta a.docker.cf.app
Showing health and status for multi-target app a.docker.cf.app in org ****** / space ****** as ******...
OK
Version: 0.0.0
Apps:
name requested state instances memory disk urls
my-mta-managed-app started 1/1 1G 1G my.my-mta-managed-app.cfapps.sap.hana.ondemand.com
$cf app my-mta-managed-app
Showing health and status for app my-mta-managed-app in org ****** / space ****** as ******...
name: my-mta-managed-app
requested state: started
routes: my.my-mta-managed-app.cfapps.sap.hana.ondemand.com
stack:
docker image: cloudfoundry/test-app:latest
Find the route assigned to the app in the previous output (of cf deploy
, cf mta
or cf app
)
-
Directly open it in a browser as https://<route>;
-
Or execute a get request from the command line
curl https://my.my-mta-managed-app.cfapps.sap.hana.ondemand.com/index
0
echo $?
0