Speed Up Docker Build using cache
Docker has become a popular tool in recent years for building and deploying applications in a portable and scalable way. However, the build process can sometimes be slow, especially for large applications with many dependencies. In this article, we’ll explore how we can optimize our Dockerfile to speed it up.
When building a rails app for production we would need to do the following steps in the docker file
|
|
Docker after building each step it will cache that step. If the instructions/context of that steps or steps before haven’t change then docker will use the cache.
So we need to make docker understand that there is no change, hence we can use the cache instead of rebuilding it.