There’s just too many issues to sift through in GitHub · Where software is built but I was wondering if there was a capability proposed in Dockerfile to do
COPY --no-time
or
COPY --mtime=0 --ctime=0
Which will strip off the time information of the files being copied. This will allow the layers to be cached better if the files may have been “modified” locally but the content was actually the same.
I could be wrong about that, but I thought layers would not be invalidated just by updating the modifiction time or creation time of the file. If it does matter, I feel it should not. I don’t see the use case when someone rebuilds an image and wants to change the time only. And if it happens sometimes for any special reason, a new RUN instruction could be addded to update that metadata.
I don’t have time to test it now, but can you confirm, you are absolutely sure the layers in the cache were invalidated because of changed mtime or ctime and not because a new line was added to the end of the file or the line endings were changed, (LF vs CRLF) or any nonprintable character was removed or added?
Changing time would be the extra thing, but creating “reproducable builds” But you’re right I tested quickly by touching a file it reused the cache layers.
For reproducibility purposes, Jib sets the creation time of the container images to the Unix epoch (00:00:00, January 1st, 1970 in UTC). If you would like to use a different timestamp, set the jib.container.creationTime / <container><creationTime> parameter to an ISO 8601 date-time. You may also use the value USE_CURRENT_TIMESTAMP to set the creation time to the actual build time, but this sacrifices reproducibility since the timestamp will change with every build.