reproducible-containers / buildkit-cache-dance

Save `RUN --mount=type=cache` caches on GitHub Actions ( Forked from https://github.com/overmindtech/buildkit-cache-dance )
Apache License 2.0
143 stars 29 forks source link

dancing with pip cache on a python image #9

Open mgaitan opened 11 months ago

mgaitan commented 11 months ago

I am attempting to use buildkit-cache-dance to cache pip dependencies in a GitHub Actions workflow but am encountering issues where the cache is not being used.

My example repo: mgaitan/pip-docker-cache-dance

Consider this commit where I removed a dependency, while supposely the rest are available in the cache.

However the logs indicates that despite the cache directive, pip dependencies are being downloaded again.

I'd appreciate any insights or assistance to resolve this issue.

henryjw commented 9 months ago

TLDR; the files are cached but it's possible that the package manage isn't accessing them

@mgaitan I used your repo to explore how buildkit-cache-dance works. After troubleshooting and adding some logs I've concluded that buildkit-cache-dance is working as expected. So my guess is that it's something about how you're installing the modules. Here's the run with all my troubleshooting logs: https://github.com/henryjw/pip-docker-cache-dance/actions/runs/7371832005/job/20059582773

screenshot of cached files

I'm not experienced enough with Python to know why it's not working for you, but for nodejs using the pnpm package manager, there are flags that must be set to tell it to give higher priority to the cached files before attempting to download them. My install script is pnpm install --prefer-offline --frozen-lockfile, where --prefer-offline tells the package manager to give priority to the existing files.