Skip to content
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

docker: improve Rust dependency caching in CI to avoid rebuilding #6169

Closed
gustavovalverde opened this issue Feb 15, 2023 · 3 comments · Fixed by #8796
Closed

docker: improve Rust dependency caching in CI to avoid rebuilding #6169

gustavovalverde opened this issue Feb 15, 2023 · 3 comments · Fixed by #8796
Assignees
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles C-design Category: Software design work C-enhancement Category: This is an improvement I-heavy Problems with excessive memory, disk, or CPU usage P-Low ❄️ S-needs-triage Status: A bug report needs triage

Comments

@gustavovalverde
Copy link
Member

Motivation

When files are copied into the Dockerfile with the COPY command, the cache can get invalidated. We could improve this by using the --link option which creates more independent layers to avoid rebuilding when not needed

Specifications

Documentation: https://docs.docker.com/engine/reference/builder/#copy---link

@gustavovalverde gustavovalverde added C-design Category: Software design work A-devops Area: Pipelines, CI/CD and Dockerfiles C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage P-Low ❄️ I-heavy Problems with excessive memory, disk, or CPU usage labels Feb 15, 2023
@gustavovalverde gustavovalverde self-assigned this Feb 15, 2023
@mpguerra mpguerra added this to Zebra Feb 15, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in Zebra Feb 15, 2023
@gustavovalverde gustavovalverde changed the title docker: improve caching by using the --link option with COPY docker: improve Rust dependency caching in CI to avoid rebuilding Sep 11, 2023
@mpguerra mpguerra removed this from Zebra Feb 20, 2024
@gustavovalverde
Copy link
Member Author

This has become a cost issue, so we should prioritize it.

@gustavovalverde
Copy link
Member Author

As caching is not working as expected, and using it takes the build more time as it's also pushing the cache to the registry, we decided to remove this here: https://github.com/ZcashFoundation/zebra/pull/8374/files#diff-5a5111df219975ea6b3b69567752b89fa0c670d5a67598674ad411da2ed96985L174-L187 in PR #8374 as it's generating costs for storing the artifacts without an actual value added.

This must be taken into consideration when working towards a solution.

gustavovalverde added a commit that referenced this issue Aug 26, 2024
This update eliminates the need for external tools like cargo-chef to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.
gustavovalverde added a commit that referenced this issue Aug 26, 2024
This update eliminates the need for external tools like cargo-chef to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.
gustavovalverde added a commit that referenced this issue Aug 29, 2024
This update eliminates the need for external tools like cargo-chef to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.
gustavovalverde added a commit that referenced this issue Aug 29, 2024
This update eliminates the need for external tools like cargo-chef to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.
gustavovalverde added a commit that referenced this issue Aug 29, 2024
This update eliminates the need for external tools like `cargo-chef` to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.
mergify bot pushed a commit that referenced this issue Sep 5, 2024
* ref(docker): leverage cache mount with bind mounts

This update eliminates the need for external tools like `cargo-chef` to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in #6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.

* chore: remove extra `WORKDIR` and imp comments

* chore: improve comment legibility

Co-authored-by: Arya <aryasolhi@gmail.com>

---------

Co-authored-by: Pili Guerra <mpguerra@users.noreply.github.com>
Co-authored-by: Arya <aryasolhi@gmail.com>
@mergify mergify bot closed this as completed in #8796 Sep 5, 2024
dmidem pushed a commit to QED-it/zebra that referenced this issue Oct 29, 2024
* ref(docker): leverage cache mount with bind mounts

This update eliminates the need for external tools like `cargo-chef` to leverage caching layers, resulting in an average build time reduction of 4m30s (~36% improvement).

While this solution doesn't fully resolve the issues mentioned in ZcashFoundation#6169 (comment), it represents the best possible approach without resorting to custom solutions, which we'd prefer to avoid.

* chore: remove extra `WORKDIR` and imp comments

* chore: improve comment legibility

Co-authored-by: Arya <aryasolhi@gmail.com>

---------

Co-authored-by: Pili Guerra <mpguerra@users.noreply.github.com>
Co-authored-by: Arya <aryasolhi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles C-design Category: Software design work C-enhancement Category: This is an improvement I-heavy Problems with excessive memory, disk, or CPU usage P-Low ❄️ S-needs-triage Status: A bug report needs triage
Projects
None yet
2 participants