micronaut-projects / micronaut-gradle-plugin

A Gradle Plugin for Micronaut
Apache License 2.0
65 stars 43 forks source link

Task buildLayers does not preserve filemtime, interfering with docker layer caching #978

Open davidhiendl opened 6 months ago

davidhiendl commented 6 months ago

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#L55

Actual Behaviour

Files are deleted and copied again at each execution, creating new timestamps for library files.

Steps To Reproduce

Environment Information

Linux but probably affects all OS's

Example Application

No response

Version

Micronaut Gradle Plugin 4.3.x