Docker containers are now an established tool for deploying applications. In this article, we highlight the advantages of a Continuous Integration and Continuous Deployment process with Docker.
Continuous Integration
As soon as more than one developer is working on an application, the challenge arises of ensuring that everything fits together. On the one hand, a version control system such as git helps us with this. Each developer commits their changes at their own pace. As soon as he or she is sure that the changes and additions can be transferred to the general code version, the changes are pushed. At this point, it must be ensured that these changes work and do not cause any damage to the existing code. It must also be ensured that the changes match the changes made by colleagues.
Before a developer pushes their own changes, the automated tests must be executed locally. This ensures that everything is in order, at least from the perspective of the individual developer. However, this is often not enough for a sufficiently large software system. It is essential to ensure that the integration of changes into the overall system does not cause any damage. This is where the continuous integration process comes into play.
All components of the system are integrated on a continuous integration server after each push. This means that the entire code base is translated. Errors can already come to light at this stage if a local change causes problems in a more distant code area that the individual developer did not have an overview of. Following the build step, all automated tests are executed. This ensures that correctness is maintained. It must be ensured that errors are detected, regardless of which tests the developer has executed locally on their machine. In the heat of the moment, local test execution is sometimes forgotten or not all tests are executed. The test execution on the Continuous Integration Server therefore represents a safety net that detects errors, regardless of the individual developer and their diligence.
The result of the continuous integration process is a deployable product. In the context of Docker, this is one or more Docker images that are uploaded to a registry. Further automated tests should be carried out against these images. These are usually integration or system tests.
Once the continuous integration process has been successfully completed, the next step is deployment.
Continuous Deployment
After a new version of the software system has been loaded into the registry through the continuous integration process, this version must be deployed. This can initially be done on a staging or test system so that the product owner or quality assurance can assess the result. Regardless of whether each individual version is tested by these people, the deployment to the staging or test system must be fully automated. On the one hand, this is more efficient than manual deployment. Secondly, automation ensures that no errors occur. All work steps required for deployment are fully automated.
When the version of the software system is released for live operation, it is automatically deployed in the production environment.
Depending on the degree of test automation, it is also possible to deploy directly into the production environment. Initially, developers will probably be reluctant to do this for fear of undiscovered errors reaching production.
However, this is not a problem, but a solution. The more care each individual developer puts into test automation and test coverage, the higher the quality of the product. At the same time, this increases confidence that the error rate will remain within narrow limits.
The continuous provision of each new version of the product challenges developers to focus on the quality of the product and the development process. This is all the easier if only one feature is worked on at a time. Instead of having many loose ends that only reach the end customer after a long delay, benefits are delivered step by step.
Interim conclusion
A well-running process of continuous integration and continuous deployment ensures that problems are identified at an early stage. The goal is a continuous process that gradually brings one requirement after another to the end customer. Code, tests and new versions only take effect when they reach the customer. The process of continuous integration and continuous deployment is intended to challenge developers to focus on the quality of the product.
Docker
Docker is a powerful tool that drastically simplifies the continuous process. The key here is reproducibility. The use of Docker provides a continuously reproducible environment. Every Docker image starts in a clearly defined environment. There are no surprises because the environment in which the software system is executed has suddenly changed. As long as nobody deploys a different version of the underlying images, everything remains reproducible and always the same.
The changeover to newer versions of the environment is carried out in a targeted manner. The test automation ensures that the system also runs correctly in the updated environment. This also applies to external resources on which the system is dependent. The same defined versions are used again and again.
If the system requires a Postgres database, for example, the same version is always used, regardless of which server the system is deployed to. The server does not have to provide the resources itself; these are also deployed as Docker containers. This means that the entire system can be deployed to more or less any server at the push of a button, on which only a Docker environment needs to be available. Another advantage: the test and production environments do not differ in this way. This ensures that all tests are executed as close to production as possible.
Conclusion
As long as a software development process is not clearly defined, there are many opportunities for errors. Each team must define and set up the process for itself. The first step is to introduce version control. Building on this, a continuous integration process is set up. This alone leads to fewer errors remaining undetected. The CI process takes a lot of the manual work and care of each individual developer out of the process.
Continuous deployment then builds on the CI process. It ensures that every developer is challenged to work properly. Because a push potentially ends up directly in the production environment. As soon as I realize this as a developer, I will ensure a high level of test coverage in my own interest.
If you are not yet convinced that Continuous Deployment is practically indispensable, you might want to take a look at the book Accelerate throw. The link between continuous deployment and corporate success is clearly demonstrated there.
You can learn the practical use of Docker in our seminar learn.