Dockerfile: don't cache s4tf toolchain tar file #49
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.
Current Dockerfile steps:
This approach has downside in case someone wants to rebuild the container often in order to get the latest version of s4tf toolchain. As the curl command in step 2 is cached by docker build system, it's only possible to re-download s4tf by disabling build cache (docker build --no-cache), which requires to re-do all the steps in Dockerfile; or by supplying different
swift_tf_url
argument value, e.g. by adding a random query param to the url, which is not very convenient and will also force docker build re-do all subsequent steps after step 2.Suggested change is to re-order steps and to use Dockerfile
ADD
command so that docker build always checks for the latest s4tf toolchain but still caches other steps as much as possible.New order:
ADD
command (that checks if the file has changed)Suggested change has own downsides that might make it not acceptable depending on the docker image use-cases:
ADD
command fully downloads the file to check if it has changed, unfortunately it's not smart enough yet to consider E-Tag header: Dockerfile ADD remote url does not use any HTTP header so always re-downloads moby/moby#15717. Since this download occurs every time you build the image, it might be too annoying in case one needs to build the image much more often than s4tf is updated.ADD
command, it is still stored in layer created byADD
command (can be avoided by squashing the image, but--squash
option is still experimental).