I think I've optimized as much as possible my Dagger code (Python SDK) by using a lot of volumes (like putting in a volume the cache for Linux apt, another volume for pip, another one for php composer dependencies and so on. For all my projects, I've, I think, go as far I can (=as far I know I can).
But this optimization has a huge weakness: changing one character in my project's codebase.
Here is an example:
Below I'm calling my phpunit function (to run unit tests in PHP) and that does a lot of initialization / downloads (think to apt-get install, pecl install (redis, phpcov), composer install, build a postgres and redis container and much more). A lot of things and it can take up to 2 minutes
dagger call --source-directory=/app/src/php --config-directory=/app/src/php/.config phpunit
If I rerun that command immediately (no change at all), caching is very powerful and it's now just a question of seconds but as soon as I change one character in my codebase (folder /app/src/php) or in my configuration files (folder /app/src/php/.config), the cache seems fully invalidated and the next call to my function will redo the full process.
In fact, if I just do a stupid change in my configuration file; I don't expect that Dagger will download again linux binaries (apt-get), composer dependencies, ... and so on.
Composer dependencies to take that example has to be rebuild only if I do changes to my composer.json.
But ... for the illustration, once I've fired my phpunit , I can call phpstan or phan or phpcbf or ... (static tools for PHP) and here, because I've not change my codebase, all caches are well reused (it's so great!) and actions are running fast.
Am I doing something wrong / how can I use Dagger cache as much as possible?
Thanks!