fagiani / apt-buildpack

apt-based Buildpack
MIT License
22 stars 31 forks source link

Cache never used #23

Open thedarkside opened 1 year ago

thedarkside commented 1 year ago

Hey @fagiani

ive started using packs image cache and for some reason this buildpack always prints -----> Detected Aptfile changes, flushing cache. Iam building inside our gitlab pipeline with gitlabs auto devops pipeline template and the paketo builder.

Even a second job run on the same commit detects a "change".

Looking into the code i suspect the comparision of the Aptfile via cmp -s as the issue. Maybe because paketo resets the timestamps of all files and thus only those differ? Im not sure how cmp behaves.

For this use here it should be save to just compare the contents and ignore any difference in file metadata.

knsita commented 9 months ago

Hi,

I'm encountering the same problem in our Gitlab Pipeline.

When rebuilding on a local machine, I don't get the ---->Detected Aptfile changes, flushing cache and the cache get's reused. After some experimenting I found out, that the buildpack cache is stored in an image, see https://buildpacks.io/docs/app-developer-guide/using-cache-image/ If I remove that image, I get the same behavior as in our Gitlab CI pipeline, where containers and images are ephemeral and get thrown away after a job.

I think you have to provide that image to the Docker deamon that is used by the build container in your pipeline.

I'll do further testing and report when I found a working solution.

knsita commented 9 months ago

Okay, I still get the --->Detected Aptfile changes, flushing cache message even when the image was found.

It would be great to know which dirs/files/images/volumes one has to back up in order to not redownload and reinstall all dependencies in the build job of the gitlab pipeline.

thedarkside commented 7 months ago

@knsita meanwhile I created a solution. The default gitlab chart is not capable of utilizing cache images for buildpack builds.

Once it's enabled it works as expected. So this is definitely not an issue of this project here!