-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
build: cache invalidation improvements #19617
Conversation
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
content/build/cache/invalidation.md
Outdated
in your Debian-based image to the latest version: | ||
|
||
```dockerfile | ||
RUN apt-get update && apt-get upgrade -y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is recommended to upgrade all packages (cc @tianon). Can you put an example with a simple package like curl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also switch to Alpine based image that has packages updated more often than Debian based distro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to apk
and curl
for this one
content/build/cache/invalidation.md
Outdated
- Make sure that a layer before it has changed | ||
- Clear the build cache ahead of the build using | ||
[`docker builder prune`](../../reference/cli/docker/builder/prune.md). | ||
- Use the `--no-cache` CLI flag or specify the `no-cache` property in the [Bake file](../bake/reference.md#targetno-cache). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should talk also about --no-cache-filter
case like we do in buildx repo for mod-outdated
:
- https://github.com/docker/buildx/blob/7eb3dfbd2267fb370ec10994847c15a650924db6/docker-bake.hcl#L119
- https://github.com/docker/buildx/blob/7eb3dfbd2267fb370ec10994847c15a650924db6/hack/dockerfiles/vendor.Dockerfile#L41
In this case we don't want to cache this specific stage because we always want to RUN
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a --no-cache-filter
example, let me know what you think.
357944f
to
699739c
Compare
content/build/cache/invalidation.md
Outdated
|
||
```dockerfile | ||
FROM alpine:{{% param "example_alpine_version" %}} AS install | ||
RUN apk add install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RUN apk add install | |
RUN apk add curl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol
content/build/cache/invalidation.md
Outdated
Suppose you have a step in your Dockerfile to upgrade all the software packages | ||
in your Debian-based image to the latest version: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need changes now that we use alpine and install curl
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
699739c
to
3fc37c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Improve documentation about how cache invalidation works for build.
Add a dedicated page describing invalidation.
Add a section about how cache invalidation works with secrets/how to force cache invalidation with build args.
main diff is here:
https://github.com/docker/docs/pull/19617/files#diff-1ca9cf4d42edf044da91b28c0c19f3dc4b07b1fca8bb2cc91dd1aa1d9c11a4b4R61-R79
Related issues
docker/build-push-action#1050 (comment)
Reviews