Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the advantage of in each deploy, building a new docker image containing the application instead of just updating the application?

I am migrating an application in Nodejs to kubernetes in GCP. In CI tutorials, I see the updated application being copied to a new docker image and sent to GCR.

The process of uploading an image is slow compared to updating only the code. So what exactly is the gain of sending a new image containing the application?

like image 534
Emerson MS Avatar asked Dec 23 '22 03:12

Emerson MS


2 Answers

You are missing the whole docker philosophy and the concept of immutable infrastructure, and the matrix from hell bellow, docker and other container-based technology was originally adopted to address the matrix from hell. enter image description here

Solution enter image description here

Entire books have been written to answer your question why not copy the code and why use the images , but the short answer is , use the docker images and address the slowness by doing some optimizations such as minimal docker images , minimal layers , caching etc

Minimal docker images

like image 112
Ijaz Ahmad Avatar answered Dec 28 '22 09:12

Ijaz Ahmad


The philosophy of Docker is simple - layers are reusable [1]. As long as the layers have not changed, they are reused across images. As long as you keep your application's layer as the last few, the base layers can be reused, keeping the number of layers pushed to a minimum. You should consider using multi-stage builds to minimise shipping build-stage dependencies with your container. Hasura.io has an excellent post[2] on using multi-stage builds for NodeJS apps effectively.

  1. https://www.infoworld.com/article/3077875/linux/containers-101-docker-fundamentals.html
  2. https://blog.hasura.io/an-exhaustive-guide-to-writing-dockerfiles-for-node-js-web-apps-bbee6bd2f3c4
like image 41
Aditya Sundaramurthy Avatar answered Dec 28 '22 09:12

Aditya Sundaramurthy