-
Notifications
You must be signed in to change notification settings - Fork 88
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
ci: use buildkit cache for dockerfile #860
Conversation
containerfiles/Dockerfile
Outdated
RUN \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ |
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.
mounting a buildkit cache to cover the cargo registry + target dir
elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCH=x86_64; fi; \ | ||
cp target/$ARCH-unknown-linux-gnu/release/$TARGETBINARY target/release/ | ||
cp target/$ARCH-unknown-linux-gnu/release/$TARGETBINARY release/; |
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.
this used to be a seperate step, but now that it is in the cache, made a single step. Copies the executable out of the cache directory into a seperate one. We might be able to replace with out_dir
if/when that is stabilized.
c2aec42
to
a5bc1b3
Compare
elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCH=x86_64; fi; \ | ||
cp target/$ARCH-unknown-linux-gnu/release/$TARGETBINARY target/release/ | ||
cp target/$ARCH-unknown-linux-gnu/release/$TARGETBINARY release/; |
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.
What's the reason for doing this? Is moving from target/$ARCH-unknown-linux-gnu/release
to target/release
invalidating the 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.
the cache is all of target/, if you run in a different command the file doesn't exist because you need to mount the cache. By moving the artifact out of the cache it persists.
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.
This is nice. Shame that cargo-chef didn't work out for our purposes. We can consider bringing it back if our dependency structure changes.
Summary
Using new buildx cache instead of cargo chef for image updates, makes subsequent updates much faster locally.
Background
Cargo chef has not created huge speed up in build times due to nature of our dependencies. In local tests it improves second build by ~1 minute while slowing first build by about 3 minutes. This makes the first local build take ~4 min and then subsequent minor updates can be built in less than 30s.
Changes
Testing
Running locally, testing image built + CI tests on here to see how it impacts CI build time.