IBM Bluemix provides built in DevOps services to manage source code and to build, test and deploy applications to Bluemix. This works well for many scenarios, esp. when deploying single applications to Bluemix via delivery pipelines. For more complex scenarios IBM provides the Continuous Delivery toolset UrbanCode to deploy hybrid applications to the cloud and on-premises and to deploy composite applications with multiple components or microservices.
In this blog entry I focus on how to deploy hybrid applications as Docker containers to Bluemix and an on-premises. My colleagues Sanjay Nayak, Noel Richard Nihill and Mike S. Samano have written an excellent article “Deploy Docker containers in hybrid clouds that use IBM UrbanCode” (part 1, part 2) where they explain how to deploy a sample store application. The store application uses one container on Bluemix which connects via the Secure Gateway to three containers running in a Docker Swarm cluster on premises. Rather than repeating the article here, I focus below on, as I think, the most interesting part which is how to link between the different containers and services.
On the on-premises Swarm cluster three containers are run. A container running a Java application (hosting REST APIs) accesses the two database containers DB2 and MySQL. To define multi-container Docker applications typically Docker Compose is used and the sample store application comes with a docker-compose.yml file. With UrbanCode you can essentially use the same information in the configuration of the containers to expose it as environment variables at runtime. The following screenshot shows the configuration of the container with the Java application.
In order to deploy containers to Bluemix you need to define configuration data like the Bluemix user name, organization, password, etc.
Rather than defining this data in multiple component definitions, they are defined once globally.
In the configuration of the container which is deployed to Bluemix the name of the Cloud Foundry bridge application is defined so that the container can access the credentials of the secure gateway service via the environment variable VCAP_SERVICES.
To find out more about UrbanCode check out the Developer Center and watch the videos UrbanCode Deploy and Docker Containers Connect the Dots, Hybrid Deployment of Docker Containers using IBM UrbanCode Deploy and IBM UrbanCode Deploy with IBM Bluemix.