chainguard-dev / apko

Build OCI images from APK packages directly without Dockerfile
https://apko.dev
Apache License 2.0
1.21k stars 125 forks source link

Re-instantiate each APK's tarfs after caching #1383

Closed jonjohnsonjr closed 3 weeks ago

jonjohnsonjr commented 3 weeks ago

On cache miss, we'll expand and APK into a tempdir, then move all the files into the final place in our cache dir. On ExpandedAPK.Close(), we'll remove that tempdir.

If we have concurrent images installing the same package, one might clean up the tempdir while the other still has a reference to the tarball sitting in the tempdir, so subsequent reads fail.

Instead, we need to re-instantiate the tarfs after we move it to the cache dir. This could be much more efficient (we re-scan the tar). I'm working on that in a separate branch, so left a TODO for now.