Why does my Docker build reinstall all dependencies on every code change? #46
Answered
by
Kevinchamplin
Kevinchamplin
asked this question in
Q&A
-
|
Why does my Docker build reinstall all dependencies on every code change? |
Beta Was this translation helpful? Give feedback.
Answered by
Kevinchamplin
Jun 13, 2026
Replies: 1 comment
-
|
Docker caches layers by instruction, and a layer's cache is invalidated as soon as anything it copied changes. If you |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Kevinchamplin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Docker caches layers by instruction, and a layer's cache is invalidated as soon as anything it copied changes. If you
COPY . .before installing dependencies, every source edit busts the install layer. Copy just the manifest first (package.json/composer.json + lockfile), run the install, then COPY the rest of the source — now deps only reinstall when the manifest actually changes.