W
W
webe2021-08-11 05:02:12
Docker
webe, 2021-08-11 05:02:12

How to reload files correctly, through an image or through a container?

I understand with docker, but I can’t understand how to re-upload the files, please tell me the basic philosophy
. Let’s say the programmer made a new commit to GIT, you need to pick up the sources, build, for example, through NPM run build
, how to do it right?

1) Based on the sources, I create a new image with these files (but be sure to delete the old container or the old image before that, because docker build -f ./dockerfile -t front . cannot overwrite the old image) then start the container again based on this image.
2) I make an image 1 time and never touch it, I also create a container 1 time, but I open something like SFTP through which I forward the ZIP and already unpack it inside the container

The main mystery for me is how to rebuild if we have new sources for, say, a site, do we really have to always stop the container completely and delete it first, delete the old image, and only after that do docker build -f ./dockerfile -t front .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-08-11
@webe

Somewhat difficult and unnecessary.
Start the desired image.
Make mount points where the source files are and where to build the result.
Run npm run build. The result is built to the mount point.
Extinguish the container.
That is, consider a container simply as an isolated code execution environment that interacts with your project through mount points. In most cases, pouring something into the container, storing code inside the container is not required.
Keeping the container running all the time is also not required if you use it for rebuilding.
The project has been updated - uploaded to the server. Started container. Messed up the sources. Container extinguished.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question