Caching Composer vendor and FFmpeg install between jobs for a PHP project

Hi everyone, I have a PHP video app whose test job installs Composer dependencies and FFmpeg (via apt) on every run, which adds 2-3 minutes each time.

For Composer I’m using save_cache/restore_cache keyed on checksum of composer.lock, which mostly works. FFmpeg is the slow part. Is it better to build a custom Docker image with FFmpeg baked in, or is there a reasonable way to cache apt packages between jobs? Also, does anyone key the Composer cache on the PHP version too, to avoid stale extensions after an image upgrade?

Thanks for any tips!

for ffmpeg id go with a custom image with it baked in, caching apt packages still leaves you paying the install step and it gets messy with dependencies. and yes, put the php version in the composer cache key too, otherwise a restored vendor dir can be stale after an image bump.