The task buildLayers does only copy files but does not set correct file mtime. The lib mtime should be preserved (or better yet use timestamp the library was actually published) to enable docker layer caching.
The problem can be traced back to the fact that gradle copy task does not preserve file mtime (by default, nor does it have an option to do so): https://github.com/gradle/gradle/issues/1252
Expected Behavior
The task buildLayers does only copy files but does not set correct file mtime. The lib mtime should be preserved (or better yet use timestamp the library was actually published) to enable docker layer caching.
The problem can be traced back to the fact that gradle copy task does not preserve file mtime (by default, nor does it have an option to do so): https://github.com/gradle/gradle/issues/1252
The problem originates in this function in the
BuildLayersTask
class: https://github.com/micronaut-projects/micronaut-gradle-plugin/blob/master/docker-plugin/src/main/java/io/micronaut/gradle/docker/tasks/BuildLayersTask.java#L55Actual Behaviour
Files are deleted and copied again at each execution, creating new timestamps for library files.
Steps To Reproduce
build/docker/main/layers/libs
and note mtimeEnvironment Information
Linux but probably affects all OS's
Example Application
No response
Version
Micronaut Gradle Plugin 4.3.x