Summary

In this chapter, you implemented a Docker workflow that tests, builds, and packages your application into a Docker image that is ready to publish and deploy to production. You learned how you can build your application in two stages using Docker multi-stage builds—the test stage uses a development environment complete with development libraries and source compilation tools that allows you to build and test your application and its dependencies in precompiled packages, while the release stage takes those built packages and installs them into a production-ready operating environment, free of development libraries and other tools, significantly reducing the attack surface of your application.

You learned how you to use Docker Compose to help simplify the various commands and actions you need to perform during the test and release stages, creating a docker-compose.yml file with a number of services, each defined in a declarative, easy-to-understand format. You learned how to replicate a number of deployment tasks required to get your application up and running, such as running database migrations, collecting static files, and ensuring the application database was healthy before you attempted to run your application. Being able to perform each of these tasks in a local environment provides you with the confidence and understanding of how these tasks will work in your actual production environments, and gives you early warning should any of your application or configuration changes break these processes locally. After starting your application in the correct state and connected to the application database, you learned how you can run acceptance tests from the point of view of an external client, which gives you great confidence that your image is working as expected, and early warning when these acceptance tests fail as part of the ongoing development of your application.

Finally, you learned how to bring all of this together in a fully automated workflow using GNU Make, which provides you with simple high-level commands that you can use to execute the workflow. You now have the ability to execute the test stage by simply running make test, run the release stage by running make release, and clean up your environment using make clean. This makes it very easy to run the workflow, and later in this book, will simplify the configuration of continuous-delivery build systems that we will be using to automatically test, build, and publish your Docker applications.

In coming chapters, you will learn how to actually publish the Docker release image you created in this chapter, but before you can do this, you need to establish an AWS account, configure access to your account, and install tools that support interacting with AWS, which will be the focus of the next chapter.