Over a million developers have joined DZone.

End-to-End Automation for Docker-based Applications on DigitalOcean


The simplicity and cost-effectiveness of DigitalOcean has driven many startups & enterprises to host their applications on Droplets distributed across different regions. However as development teams start to grow or as enterprises embark on new development projects, replicating consistent DEV/TEST environments for the quickly growing teams becomes a struggle on any cloud infrastructure.

DCHQ simplifies the containerization of enterprise applications and makes it possible to replicate very complex application environments on multiple hosts through a one-click deploy button. DCHQ does not just automate the application deployments, but it also integrates with DigitalOcean to automate the provisioning and auto-scaling of Weave-enabled clusters consisting of distributed Droplets.

In this blog, we will go over the automated infrastructure provisioning on DigitalOcean as well as the automated deployment and lifecycle management of a multi-tier application.

First, a user can register a Cloud Provider for DigitalOcean by navigating to Manage > Repo & Cloud Provider and then clicking on the + button to select DigitalOcean. The DigitalOcean Access Token needs to be provided – which can be retrieved from the API section of the DigitalOcean console.

DigitalOcean Cloud Provider on DCHQ

A user can then create a Weave-enabled cluster with an auto-scale policy to automatically spin up new Droplets. This can be done by navigating to Manage > Data Center & Cluster page and then clicking on the + button. You can select a capacity-based placement policy and then Weave as the networking layer in order to facilitate cross-container communication across multiple hosts within a cluster. The Auto-Scale Policy in this example sets the maximum number of VM’s (or Droplets) to 10.

DigitalOcean Cluster on DCHQ

A user can now provision a number of Droplets on the newly created cluster by navigating to Manage > Bare-Metal Server & VM and then clicking on the + button to select DigitalOcean. Once the Cloud Provider is selected, a user can select the region, size and image needed. Ports can be opened on the new Droplets (e.g. 32000-59000 for Docker, 6783 for Weave, and 5672 for RabbitMQ). A Data Center (or Cluster) is then selected and the number of Droplets can be specified.

DigitalOcean Droplet Provisioning on DCHQ

Once the droplets are provisioned, a user can deploy a multi-tier, Docker-based application on the new Droplets. This can be done by navigating to the Self-Service Library and then clicking on Customize to request a multi-tier application. In this example, we have a multi-tier application consisting of Nginx (for load balancing), Tomcat (the clustered application server) and MySQL (as the database). You will notice Nginx is invoking a BASH script plug-in to add the container IP’s of the application servers in the default.conf file dynamically (or at request time). Tomcat is also invoking a BASH script plug-in to deploy a Java WAR file from a specified URL. You will notice that the cluster_size parameter allows you to specify the number of containers to launch (with the same application dependencies). The host parameter allows you to specify the host you would like to use for container deployments. Here are the values supported for the host parameter:

  • host1, host2, host3, etc. – selects a host randomly within a data-center (or cluster) for container deployments
  • <IP Address 1, IP Address 2, etc.> -- allows a user to specify the actual IP addresses to use for container deployments
  • <Hostname 1, Hostname 2, etc.> -- allows a user to specify the actual hostnames to use for container deployments
  • Wildcards (e.g. “db-*”, or “app-srv-*”) – to specify the wildcards to use within a hostname

A user can select an Environment Tag (like DEV or QE) and the Data Center created for DigitalOcean before clicking on Run.

Multi-Tier Docker App on DCHQ

Image title

Once the application is up and running, a user can monitor the CPU, Memory, & I/O Utilization of the running containers and perform day-2 operations like Backup, Container Updates using BASH plug-ins, Scale In/Out and Continuous Delivery.

In the recorded demo, we scaled out the application server cluster from 2 to 3. We then used the BASH plug-in to update Nginx’s default.conf file so that it’s aware of the new application server added.

Manage Docker App Life-Cycle on DCHQ

Scale Out Dokcer Apps on DigitalOcean using DCHQ

Update Dokcer Apps on DigitalOcean using DCHQ

Sign Up Now for FREE on DCHQ.io Hosted PaaS  (http://dchq.io

docker ,digitalocean ,paas ,iaas ,app development ,application lifecycle management ,containerized applications ,linux containers ,deployment automation

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}