Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted not including build args in cache key #739

Merged
merged 1 commit into from
Aug 16, 2019

Conversation

dzoeteman
Copy link
Contributor

@dzoeteman dzoeteman commented Aug 16, 2019

#639 removed adding the build args to the cache key. This caused build args to not be considered in at least certain scenarios for caching. An example:

ARG testarg='false'
RUN if [ "$testarg" = 'false' ]; then \
        echo "test1" > /testfile; \
    else \
        echo "test2" > /testfile; \
    fi

Running this build without build arg first, would result in test1 in the /testfile file. However, on subsequent builds with caching, even when including --build-arg "testarg=true", would still result to test1 in the /testfile file.

I've decided to simply revert the change. This seems to work correctly, and cached layers are still used if the build args are not different.
While a better solution might need to be researched long-term, I think this is not a bad solution to fix the current regression.

Fixes #690
Fixes #728

@dzoeteman
Copy link
Contributor Author

@priyawadhwa You mentioned in #639 (comment) to cc you for this fix, it would be great if you (or someone else) could take a look at this. Thanks :)

Copy link
Collaborator

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, thanks for fixing this!

@priyawadhwa priyawadhwa merged commit 48e25aa into GoogleContainerTools:master Aug 16, 2019
@dzoeteman dzoeteman deleted the build-args-cache branch August 16, 2019 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARG/ENV does not invalidate build cache Issue with caching and build arguments
3 participants