paketo-buildpacks / libpak

An opinionated extension to the libcnb Cloud Native Buildpack Library
Apache License 2.0
15 stars 17 forks source link

Caching bug when changing architectures #348

Open dmikusa opened 2 months ago

dmikusa commented 2 months ago

Expected Behavior

When you build an image on AMD64, and then switch to ARM64, the cache is not invalidated. I would expect that the cache is invalidated where appropriate.

Current Behavior

Cached items are not invalidated based on architecture changes.

Possible Solution

I think we can handle this in libpak, so that individual buildpacks don't need to know all handle this. If we look at the present architecture, we can compare that to metadata from previous installs. If the arch changes, then invalidate the cache on that layer and recreate it.

Steps to Reproduce

See https://github.com/paketo-buildpacks/spring-boot/issues/491#issuecomment-2183052097

Motivations

This is not a huge problem as most people can't just change their architecture, but on Mac M-series laptops you can. You can build for both architectures. This is where you can run into this problem.