Manifest files: Understand domain and host property for your Bluemix Cloud Foundry apps

By Henrik Loeser

Manifest files: Understand domain and host property for your Bluemix Cloud Foundry apps

Recently, I was looking over a complex app scenario to be deployed to IBM Bluemix. The solution consisted of multiple apps. Each app required their specific configuration, including the intended URLs. Fortunately, the entire solution could be deployed to Bluemix Cloud Foundry with a single “push” command.

Here’s how:

Manifest File for Multiple Apps

Bluemix Cloud Foundry allows multiple apps to be described with a single manifest file. That is, properties for several apps (or services) can be put together into a single file. For each app, its name and the location where its code is found need to be specified. They’re shown in blue in my sample manifest file below. The code for the app named “python-app” is located in the path “./top/”, whereas the “node-app” is found in the path “./lower/”.

To deploy each app to a specific machine, they need the host and domain name property be set. Typically, the host and domain name together build the URL for the app. Users access the app by visiting http://host.domain. In the example below, the host and domain property are marked in bold italic. The first app has the host “yourname-demo-app-python” and the two domains “example.com” and “eu-gb.mybluemix.net”. The second app has two host names, but no domain name specified. It means that the default domain, in my example “eu-gb.mybluemix.net”, is used.

The file “manifest.yml”:
applications:
- name: python-app
memory: 256M
command: python myapp.py
host: yourname-demo-app-python
domains:
- example.com
- eu-gb.mybluemix.net
path: ./top/
- name: node-app
hosts:
- yourname-demo-app-node1
- yourname-demo-app-node2
memory: 256M
path: ./lower/

Pushing the Apps

Once I was done with the manifest file, all I needed to do was to deploy the apps. From the directory where the file is located, simply execute the CLI command “cf push”. If you want to run the push from another location in the file system or if your manifest file is named differently, the “-f” option tells the Cloud Foundry CLI where to look for the manifest file: “cf push -f manifest2.yml”.

When I executed the push command, the following processing steps were shown. The CLI states the manifest file, then shows where the first app is created. Thereafter, the different routes are created and then bound to my app. Something similar is happening later on for the second app. The host and domain names are as specified in the manifest file, composing the URLs for the apps.

You can access the sample apps, ready for deployment, in my GitHub repository at https://github.com/data-henrik/Bluemix-ContextPathRouting. Try it yourself and experiment with deploying multiple apps at once.

cf push
Using manifest file manifest.yml
...
Creating app python-app in org hloeser@xx.ibm.com / space data_henrik as hloeser@xx.ibm.com...
OK
Creating route yourname-demo-app-python.example.com...
OK
Binding yourname-demo-app-python.example.com to python-app...
OK
Creating route yourname-demo-app-python.eu-gb.mybluemix.net...
OK
Binding yourname-demo-app-python.eu-gb.mybluemix.net to python-app...
OK
...

Creating app node-app in org hloeser@xx.ibm.com / space data_henrik as hloeser@xx.ibm.com...
OK
Creating route yourname-demo-app-node1.eu-gb.mybluemix.net...
OK
Binding yourname-demo-app-node1.eu-gb.mybluemix.net to node-app...
OK
Creating route yourname-demo-app-node2.eu-gb.mybluemix.net...
OK
Binding yourname-demo-app-node2.eu-gb.mybluemix.net to node-app...
OK

Sign up for Bluemix. It’s free!

Be the first to hear about news, product updates, and innovation from IBM Cloud