Skip to content

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Mar 24, 2025

We almost never cache the Rust build in Docker, because it always changes, because the version injected is always different.
The thing is, we always export the build cache in the CI, which always includes this huge layer, as it includes the target/ directory.

This changes so that the cargo build uses a cache mount, which means that:

  • local rebuilds are faster
  • CI builds don't try to cache the target/ directory, making them (in theory) faster to export. Before: 214s to export cache, after: 27s

Copy link

cloudflare-workers-and-pages bot commented Mar 24, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6903c3d
Status: ✅  Deploy successful!
Preview URL: https://407b61ac.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-ci-docker-cache.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose added the Z-Build-Workflow Add this label to trigger a build workflow for this pull request label Mar 24, 2025
@sandhose sandhose requested a review from reivilibre March 24, 2025 16:37
@sandhose sandhose added A-CI Related to continuous integration/GitHub Actions A-Container Related to the Docker container T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. Z-Build-Workflow Add this label to trigger a build workflow for this pull request and removed Z-Build-Workflow Add this label to trigger a build workflow for this pull request labels Mar 24, 2025
Copy link
Contributor

A build for this PR at commit 692aea6 has been created through the Z-Build-Workflow label by sandhose.

Docker image is available at:

  • ghcr.io/element-hq/matrix-authentication-service:pr-4289
  • ghcr.io/element-hq/matrix-authentication-service:sha-692aea6

Pre-built binaries are available through the workflow run artifacts.

@github-actions github-actions bot removed the Z-Build-Workflow Add this label to trigger a build workflow for this pull request label Mar 25, 2025
Comment on lines +117 to +118
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/app/target \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't easily tell, but should these have id=mas-<unique ID> so that they don't share the same cache with other dockerfiles that have caches in these locations?
(Under podman it seems like they might just hash the target option and use that as the cache key)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erf, not sure it really matters honestly? 🤷
We can always change that later

@sandhose sandhose merged commit c24c3ee into main Mar 25, 2025
43 of 50 checks passed
@sandhose sandhose deleted the quenting/ci-docker-cache branch March 25, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Related to continuous integration/GitHub Actions A-Container Related to the Docker container T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants