Comments (3)
we noticed that if the source code were to change (like a simple test.txt file being added, or an index.js file being manipulated), our RUN yarn install would no longer be cached.
This is expected with your Dockerfile above that uses COPY .
. This will copy different files, resulting in different end build result. Different files would also be visible to the yarn install
command so it would need to run again.
Cache mismatches are common if you use COPY .
, for example git clone
does not create a .git
directory in a deterministic way. If you reduce the files used by your build to only files that you actually need, you reduce the chance of cache invalidation.
If you have a reproducible case/steps where you think cache is not matched properly you can post that and we can look at the specifics.
from buildkit.
This is expected with your Dockerfile above that uses
COPY .
. This will copy different files, resulting in different end build result. Different files would also be visible to theyarn install
command so it would need to run again.
I don't see how the COPY .
that is happening after the RUN yarn install
step invalidates the previous step?
yarn install
is only interacting with with the package.json and yarn.lock file, and running this Dockerfile locally with Docker does not produce the same cache invalidation issues as it does with buildkit.
I tested with pruning all my Docker cache, running it once, adding a test.txt file and running build again, and as shown here, the yarn install
is still cached.
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 261B 0.0s
=> [internal] load metadata for docker.io/library/node:18-alpine 0.5s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [build 1/6] FROM docker.io/library/node:18-alpine@sha256:4837c2ac8998cf172f5892fb45f229c328e4824c43c8506f8ba9c7996d702430 0.0s
=> [stage-1 1/2] WORKDIR /app 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 446B 0.0s
=> CACHED [build 2/6] WORKDIR /app 0.0s
=> CACHED [build 3/6] COPY package.json yarn.lock .npmrc /app 0.0s
=> CACHED [build 4/6] RUN yarn install --network-timeout 100000 0.0s
=> [build 5/6] COPY . /app 0.0s
=> [build 6/6] RUN yarn build 1.2s
=> CACHED [stage-1 2/2] COPY --from=build /app/dist /app/dist 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:4b77c51068465e05ea438134e137de21bbb3c69f287d78e9ffdd81c767df62cf
I'll create a reproducible case early week, just wanted to get initial thoughts out quickly 😊
from buildkit.
Related Issues (20)
- S3 touch fails on files greater than 5GB in size HOT 3
- wishlist: annotations on docker/dockerfile images HOT 2
- WCOW fails to load custom frontend HOT 3
- Proposal: Use referrers api to import/export inline type cache
- bake does not merge compose services/<service>/build/x-bake setting with serivice extensions
- copy --parents silently ignores nonexistent paths HOT 2
- buildkit WCOW cannot seemingly run `RUN powershell ...`, while vanilla dockerd can HOT 4
- Proposal: csv syntax for git repos HOT 3
- Support extracting `ADD --checksum=.. https://.. ..` HOT 6
- 0.13.2 corrupts cache and cannot start (`go.etcd.io/bbolt.(*freelist).read`, `panic: invalid freelist page: 0, page type is unknown<0`) HOT 5
- can't add CA cert for gha remotecache?
- Inconsistencies in RUN mount options parsing/handling HOT 1
- dockerfile: Add integration test for ARG with empty value and default
- [v0.13] It seems that "registry.insecure=true" doesn't work. HOT 7
- buildkit remote cache fails if manifest is larger than 1MB
- Windows buildkit: copy context error HOT 6
- Proposal: lint disable controls HOT 4
- windows differ is not implemented HOT 1
- `FROM --platform=$BUILDPLATFORM a as b` not overriding `TARGETPLATFORM` for multi-stage builds HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildkit.