The DevOps 2.1 Toolkit:Docker Swarm
上QQ阅读APP看书,第一时间看更新

Continuous Delivery and Deployment with Docker Containers

In software, when something is painful, the way to reduce the pain is to do it more frequently, not less.
                                                                                                            – David Farley

At the time, we could not convert the Continuous Integration (CI) into the Continuous Delivery (CD) process because we were missing some essential knowledge. Now that we understand the basic principles and commands behind Docker Swarm, we can go back to the end of the Chapter 1, Continuous Integration with Docker Containers. We can define the steps that will let us perform the full CD process.

I won't go into Continuous Delivery details. Instead, I'll pitch it as a single sentence. Continuous Delivery is a process applied to every commit in a code repository and results in every successful build being ready for deployment to production.

CD means that anyone, at any time, can click a button, and deploy a build to production without the fear that something will go wrong. It means that the process is so robust that we have full confidence that "almost" any problem will be detected before the deployment to production. Needless to say, CD is an entirely automated process. There is no human involvement from the moment a commit is sent to a code repository, all the way until a build is ready to be deployed to production. The only manual action is that someone needs to press the button that will run a script that performs the deployment.
Continuous Deployment (CDP) is one step forward. It is Continuous Delivery without the button. Continuous Deployment is a process applied to every commit in a code repository and results with every successful build being Deployed to production.

No matter which process you choose, the steps are the same. The only difference is whether there is a button that deploys the release to production.

At this point, it is safe to assume that we'll use Docker whenever convenient and that we'll use Swarm clusters to run the services in production and production-like environments.

Let's start by specifying the steps that could define one possible implementation of the CD/CDP process:

  1. Check out the code.
  2. Run unit tests.
  3. Build binaries and other required artifacts.
  4. Deploy the service to the staging environment.
  5. Run functional tests.
  6. Deploy the service to the production-like environment.
  7. Run production readiness tests.
  8. Deploy the service to the production environment.
  9. Run production readiness tests.

Now, let's get going and set up the environment we'll need for practicing the CD flow.