Continuous delivery and containerized, microservice-based architectures are the reason SaaS darlings like Netflix and Etsy ship improvements to their customers 20+ times a day. With the help of Bamboo and Docker – and this 2-part blog series – your team can get there, too.

In this post (part 1), I’ll show you how to use Docker and Bamboo to create the build agents that power your continuous delivery pipeline. Think of it as a shortcut for scaling builds, tests, and deploys up or down. I’ll also cover containerizing build artifacts for easy sharing. Then in part 2, we’ll talk about using Docker and Bamboo to build your web app.

Btw, if you want a tutorial on getting started with Docker, take a quick detour to this post from Docker fan-boy and Atlassian developer advocate Nicola Paolucci. He’ll show you the basics of setting up Docker on your local machine and using it to build a web app from the command line.

Understanding the components

First, let’s define the various components we’ll use to create build agents with Docker.

What is a build agent?

A build agents are the virtual machines inside Bamboo that execute the steps in your build – they serve the same purpose build slaves in Jenkins. To successfully execute builds, each agent must be configured with whatever capabilities your build requires. For example, if git checkout is one of the steps, your build agent must have Git installed.

What is the Docker engine?

“Docker engine” is a commonly used term that simply refers to your installation of Docker.

What is a Docker image?

Docker images are essentially blueprints for building and running an instance of an application. When creating a Docker image, you define everything needed to run an application or service: operating system, database, binaries, etc. When you need to scale up, you use the image to fire up new nodes – or in Docker-speak, “containers”.

What is a Docker container?

Containers are instances of an image. By containerizing your application, you guarantee it’ll run the same in every environment, every time you run it.

What is a Docker agent?

When you run a Bamboo build agent inside a Docker container, we call that a “Docker agent”.

What are Docker tasks?

“Task” a Bamboo-specific term, representing a step in your build process such as checking out code, executing Junit, sending binaries to a host, etc. Docker tasks are the three Docker-flavored things Bamboo does out of the box:

  • Create a Docker image
  • Push a Docker image to a Docker registry
  • Run a Docker container

Docker tasks will come into play when we talk about using Bamboo to containerize builds of your application.

Creating build agents with Docker

Using Docker agents has a couple advantages over configuring build agents individually:

  • You can run multiple build agents on the same host without running into conflicting requirements. Let’s say, for example, one build agent needs to have Postgres 9.4, and another needs Postgres 9.5. – wrapping both agents in a Docker container lets you run them on the same host without having to mess with workarounds or environment variables.
  • It’s easy to distribute changes to build agents, and to use scripts for creating and maintaining agents. Once you have an image, you can re-use  it and skip the time-consuming manual process of installing all the necessary executables and applications on each agent.

We have two build agent images on Docker hub: a base agent, and a Java agent. Both can be used as-is, or customized to suit your needs. Once you have Docker installed, pull down these images and use them to create build agents in Bamboo – refer to the Bamboo docs for more details on getting started.

Like other build agents running on any other remote server, Docker agents appear under the Online remote agents tab once they’re up and running. At that point, they’re at your disposal to run builds, tests, and deployments.

Using Bamboo to Dockerize your application

“But wait: there’s more…”

You can also use Bamboo to containerize your build artifacts. Just add the Docker task to your build set-up in Bamboo, select the “Build a Docker image” command, and customize it using the options available.

DockerAgentSSS_03

Let’s review a typical use case.

I have a build that generates an artifact. I also have teams around me who need that same artifact. And let’s say they don’t all run the same version of Java, or don’t already pull in all the dependencies needed to use my artifact. No problem.

I can use Bamboo to package that artifact and it’s dependencies in a container using the “Build a Docker image” command. I add a task to run and test the artifact to make sure I’m giving those other teams something usable. Finally, I add another instance of the Docker task, but select the “Push a Docker image to a Docker registry” command this time.

 

DockerAgentSSS_03

Thus, my downstream teams can grab that container and incorporate it into their CD pipeline, or just run it. Either way, containerizing your build artifacts saves them a ton of time (and headaches).

 

Using Docker and Bamboo together helps you scale your continuous delivery pipeline through easy, reliable build agent creation, and easy artifact sharing. If you’re not a Bamboo user yet, start a free trial and see for yourself what it can do. And don’t forget to pull down those agent images.

Happy building!

Grab build agent images from the Docker hub

Docker containers, Bamboo, and winning at continuous delivery