docker: Build with persistent cache#273
Open
Rongronggg9 wants to merge 3 commits into
Open
Conversation
Otherwise it keeps downloading 1.90 according to rust-toolchain.toml. Fixes: 78f36a1 ("chore: bump rust version to 1.90.0") Signed-off-by: Rong Zhang <i@rong.moe>
Cache downloaded and generated files with `RUN --mount=type=cache', so that later builds don't need to download and build everything from scratch. Some Docker versions could run into bugs when a later stage accesses a cached directory from previous stages, so copy the binaries into a separate directory first. Doing so also allows Stage 2 to merge multiple `COPY --from=builder' steps into a single one. Link: https://docs.docker.com/build/cache/optimize/#use-cache-mounts Signed-off-by: Rong Zhang <i@rong.moe>
Building Sashiko requires both clippy and rustfmt to be installed. They were implicitly downloaded and installed during `cargo build', which is not optimal as they couldn't be cached properly unless the `--mount=type=cache' directories cover them as well. However, covering them with `--mount=type=cache' is overkill. Simply installing them first in a dedicated step allows the persistent cache to cover them as well, so that the build step won't repeatedly download and install them in each build attempt. Signed-off-by: Rong Zhang <i@rong.moe>
1d9918b to
af1a967
Compare
Author
|
Added a new commit to cache the installations of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cache downloaded and generated files with
RUN --mount=type=cache, so that later builds don't need to download and build everything from scratch.Some Docker versions could run into bugs when a later stage accesses a cached directory from previous stages, so copy the binaries into a separate directory first. Doing so also allows Stage 2 to merge multiple
COPY --from=buildersteps into a single one.This series also bumps rust image version to 1.90, otherwise it keeps downloading 1.90 according to
rust-toolchain.toml.Link: https://docs.docker.com/build/cache/optimize/#use-cache-mounts