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

Fix docker layers caching in CI #76

Open
wants to merge 3 commits into
base: release
Choose a base branch
from
Open

Conversation

diegoximenes
Copy link
Contributor

@diegoximenes diegoximenes commented Aug 27, 2024

Resolves NIT-2643

Fix docker layers caching in CI.

It doesn't improve CI running time by much though, something around 20% better.

You can check it working by re-running the CI workflows of this PR, or creating a new PR that doesn't modify Dockerfiles based on the branch of this PR, and check cache being hit.

@diegoximenes diegoximenes force-pushed the fix_ci_cache branch 15 times, most recently from 8ec259f to 658d286 Compare August 28, 2024 14:02
@diegoximenes diegoximenes changed the title Fix ci cache key Fix docker layers caching in CI Aug 28, 2024
@diegoximenes diegoximenes marked this pull request as ready for review August 28, 2024 17:30
@Tristan-Wilson
Copy link
Member

This looks good but I'm trying to understand it. Why does docker compose not cache the layers and we have to explicitly set a cache dir and use buildx?

@diegoximenes
Copy link
Contributor Author

This looks good but I'm trying to understand it. Why does docker compose not cache the layers and we have to explicitly set a cache dir and use buildx?

Here are some references related to docker layer caching not being natively supported in GitHub actions:

We need to explicitly set a cache dir so actions/cache@v3 and docker buildx can use it.
docker buildx will build images trying to retrieve docker layers from this dir, and will save built docker layers into this dir.
We are not able to replicate that behavior with docker compose.
To run a image, docker compose will use the images built through docker buildx.
In the end of this workflow, actions/cache@v3 will be responsible to save what is stored in this dir, so it will be able to restore into this dir in the beginning of this workflow in future GitHub actions runs.

Tristan-Wilson
Tristan-Wilson previously approved these changes Sep 30, 2024
@diegoximenes
Copy link
Contributor Author

Requesting review again after resolving git conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants