Fix caching being busted by moving .profile update to end of build phase #842
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Successor to #840
As first discussed in Discord, this node_modules path addition in the install phase is invalidating the docker cache every single time for us in CI, causing npm modules to always be installed even when optimizing only_include_files.
Here you can see two different build runs where
RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile
invalidates the cache.Since RUN commands are not supported to break caching, it seems maybe it's a bug in docker?
This Fix
Since
.profile
is used for interactive shells, and that will only happen afterstart
, we can move those to the end of the build phase, where busted. caching is no longer a big issue.This PR moves all of the
.profile
path updates to the end of the build phase, and before the start phase.It separates the
ENV
and theRUN
commands for a given path update.Before:
After:
I had to make one small tweak to the ruby install step to keep it working with this change.
Here's a full generated dockerfile for ruby + node app: