Jib: Allow setting file timestamps from plugins

Created on 8 Apr 2019  路  7Comments  路  Source: GoogleContainerTools/jib

From #1079

arejib-gradle-plugin arejib-maven-plugin

All 7 comments

Although https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified is not the best way to determine whether a resource has changed it is still a possible way to do so. Setting the file timestamps to zero/a fixed arbitrary value invalidates all results that would be generated by this mechanisms. Since this tool does not create a jar for the projects classes there aren't any other metadata to extract the age of the image from at all. Setting the file timestamp to the current timestamp is often better than setting it to zero. The following article describes the usage of the file timestamps with spring:
https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/last-modified.html

On a side node, in most bigger projects there are quite a few classes that are generated automatically and might contains comments such as Generated on XXX these would invalidate the reproducible builds anyway so we should change your policy from reproducible to predictable.

Thanks for the input, @ST-DDT.

Setting the file timestamp to the current timestamp is often better than setting it to zero.

Aside from the current timestamp, do you also see a need to set an arbitrary timestamp (for some files or all files)?

And note that, as soon as you assign the current timestamp to files (and not using a fixed timestamp), whenever you build a new image, the layers will always be considered different: https://github.com/GoogleContainerTools/jib/issues/1079#issuecomment-479220028

I would prefer the git commit timestamp as the timestamp for all files, but I can imagine that other users will use other SCM-tools with a similar timestamps. Setting each file to their individual last changed date (from scm) might be an alternative (to only rebuild the layers if they are acutally different), but this is probably too hard to implement. AFAICT I don't need the timestamps on .jars (or .classes)

Sounds like you don't need a feature to explicitly configure file timestamps to a fixed value, for example, as long as Jib supports automatically setting timestamps of all the files in the image to the timestamp of the last git commit. Can you confirm that? We are trying to see if there actually exists a use case for configuring an explicit value to design an optimal way of file timestamp configuration.

If jib adds a "use git commit timestamp option" then I dont need the option to set it to parameter x.

It just feels a little bit redundant to make jib read the git timestamp, if other plugins do that already and provide these values for other plugins. Also it would be less flexible then setting it to a parameter/option.

I need Allow setting file timestamps from plugins銆俧ixed #1800

1.5.0 released with the feature to configure the file modification times. See the jib.container.filesModificationTime doc for Maven/Gradle.

For configuring the container creation time, see https://github.com/GoogleContainerTools/jib/issues/1609#issuecomment-522658237.

@soulmz @nobecutan @mbonato @devinrsmith @yamass

Was this page helpful?
0 / 5 - 0 ratings