How do I use Docker to build releases?

I did an interview with a company a while ago and they mentioned that their apps are packaged with Docker. They also said that when they change the application, they will not only transfer the code, but the entire image. So a release is just pushing a commit from git (?).

I haven't had a chance to ask for more details, so I'm not sure what they meant ...

Option 1:

They actually put the Dockerfile in the source tree somewhere and they commit that, and then some script will just copy the compiled application in the right directory (we're talking java).

Option 2:

They capture the entire image (?). I am not familiar with the structure of Docker images, they are binaries or just a big tree of directories with distribution files (plus configuration for the application, etc.).

Or whatever ... I don't know docker enough.

Obviously I don't want to put sources in images and pipe the entire distribution to git, seems to have overdone it a bit with me ...

+3


source to share


1 answer


I think this is somewhere between Option 1 and 2:
When any of the developers on the team pushes the code, some CI / CD tools like Jenkins can build a Docker container using the base docker image (can pull the docker image directly or build an image using Dockefile), and compile java to this container. At this point, if the image has been built, the Dockerfile

person in charge of creating the image can do git pull

either ADD

or mount with Volume

and then compile the java project. Alternatively, if the base image already exists with a base environment setup, the java source can be added using volume or with another Dockerfile

referencing the base image and usingADD

or execution git pull

to create a new image and ultimately create a container where the code is compiled. In addition, the test may require a separate data container containing the data. Now the same container can be pushed over other environments, say QA or Pre-prod for unit testing and integration testing (totally design dependent). If all tests pass, the CI / CD tool can make a container to create a new image, marking it for release. The same image (with this specific tag) is now used to deploy the container in production.
Now, as you mentioned, the Dockerfile could be committed somewhere in the source tree, or it could belong to a completely different repo just responsible for deploying.
Docker images can be tied to the build pipeline and tagged accordingly to revert changes if needed.
There are many ways to integrate Docker into a version.
You can refer to these posts to further explore how people use Docker in production:
1. fooobar.com/questions/43209 / ...
2. Managing a Docker container in a production environment
3. Building a UAT / Production Docker image
Hope this helped you to some extent. This is a simple use case, I'm sure people are actually using a very elegant design with Docker in their products.



+1


source







All Articles