L
L
LVitA2021-05-20 18:49:41
GitLab
LVitA, 2021-05-20 18:49:41

How can you optimize the container build during deployment?

Good day!

I got a project that is currently being deployed using gitlab with docker-compose utility commands on the server (at the moment this command looks like this: docker-compose -p prod_front -f docker-compose-prod.yml up -d --build --remove-orphans).
The application itself is written in python using django and it is assembled in a container, which is built with each deployment. During the build of the container, dependencies from requirements are installed each time, which is why the deployment takes a rather long time.
60a684c42a8a4472196305.png
On past projects, I saw how devops solved this problem in the following way: a separate container was built with everything necessary for the project, and then it was separately connected to the container with the project, so time was not wasted installing all the dependencies.
But the following is not entirely clear to me:
1. how does gitlab understand that the dickerfile or requirements have changed and it is necessary to rebuild the container with dependencies for the project?
2. how to specify in the dockerfile with the project which container with dependencies that was built / rebuilt should be used?

If there are other good solutions, please tell me, I will be very grateful to
you. If you know good articles that describe the solution, then it will be even better.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question