Skip to content

dockerfile: add (ADD|COPY) --timestamp=<RFC3339Nano> - #2911

Closed
AkihiroSuda wants to merge 1 commit into
moby:masterfrom
AkihiroSuda:addcopy-timestamp
Closed

dockerfile: add (ADD|COPY) --timestamp=<RFC3339Nano>#2911
AkihiroSuda wants to merge 1 commit into
moby:masterfrom
AkihiroSuda:addcopy-timestamp

Conversation

@AkihiroSuda

Copy link
Copy Markdown
Member

(ADD|COPY) --timestamp=<RFC3339Nano> would be useful for more reproducible builds.

e.g.,

FROM busybox AS base
RUN echo hello >/hello

FROM scratch
COPY --from=base --timestamp="2006-01-02T15:04:05Z" /hello /hello

Closes #2910

`(ADD|COPY) --timestamp=<RFC3339Nano>` would be useful for more reproducible builds.

e.g.,
```dockerfile
FROM busybox AS base
RUN echo hello >/hello

FROM scratch
COPY --from=base --timestamp="2006-01-02T15:04:05Z" /hello /hello
```

Closes issue 2910

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@tonistiigi

tonistiigi commented Jun 17, 2022

Copy link
Copy Markdown
Member

@AkihiroSuda Do you have more use cases in mind than reproducible builds. I've been working on SOURCE_DATE_EPOCH support in master...tonistiigi:source-date-epoch . Eventually, if this is set it should set timestamps for all copies in Dockerfile automatically. Currently, it is a build arg but if we want it to be set in Dockerfile as well, then could be a build directive, #epoch= etc.

@tonistiigi

Copy link
Copy Markdown
Member

Also, looks like there is a related bug in LLB layer that needs to be fixed as well for this #2884

@AkihiroSuda

Copy link
Copy Markdown
Member Author

#epoch=

SGTM if it applies to http and local source ops as well as to exporters

@hanikesn

Copy link
Copy Markdown

I'd love to revisit this idea. I currently worked on making our builds reproducible and timestamps of files were a major issue. Unfortunately I can't use rewrite-timestamp as it's way quite slow for interactive builds as the rewrite step is not cached at the respective layers.

Fixes the problem only partially as we have a quite big monolithic Dockerfile (thanks to bake ❤️). And we mostly have 1-2 build steps in the final image were the timestamps matter. Now that I'm writing this I'm wondering whether applying rewrite-timestamp at the layer level so it's cached would be the better approach (at least usability wise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dockerfile: add (ADD|COPY) --timestamp=<RFC3339Nano>

3 participants