Proper DOCKER CACHING: Speed up your build with this optimized Dockerfile

preview_player
Показать описание
Docker relies quite heavily on caching, however, if you change a file, a cached layer often has to be rebuilt. With the tips you learn in this video, you can tweak your Dockerfile, so a simple change in your source code won't make you lose all your cached layers!
Рекомендации по теме
Комментарии
Автор

This video is 3 years old found it now.
And you have awesome content on your channel.

blank
Автор

Another possible optimization is to use "npm ci" instead of "npm install" which is significantly faster

caracallaavg
Автор

Great content on this channel. Keep up the good work!

On a completely different side-note, I love your terminal/shell settings. Any chance of sharing your .zshrc file, plugins and themes? I'm especially interested in that bottom status bar and how it could be used to always show contextual information like the current kubernetes context.

Thank you.

dredzul
Автор

What shell are you using? Looks very cool.

ttmofy
Автор

Thanks for the video, I have simple question.


In the Dockerfile, for the caching purpose, we copy package and package lock to the working directory, then install it.


It's going to generate node modules after installing it, what I'm wondering is, if you then execute COPY . ., then wouldn't it overwrite the modules that we installed previously?

junwonjung
Автор

Hello. Thanks for the video.
What's best practice for using docker and CI? I mean should we install dependencies, compile project in CI and after that wrap dist in docker container or we should do build steps in docker?

oxtyskb
Автор

Great video, but can this technique also be use in asp core nuget restore scenario?

alberte
Автор

That's great, but at the moment in our CI (gitlab) we have separate stages. First we pull dependencies, then run tests and lints in parallel, then we build application and finally we build docker image and push it to registry. Each of the stages are being run in docker containers and the final docker build is a docker-in-docker. Do you think we can somehow improve this build with a docker cache? We could put it all in single Dockerfile, along with tests and lints, but we lose clear indication what went wrong... and it just seems strange to do so.

burnsnewman