Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File copy modification timestamp is off #4057

Open
orishuss opened this issue Apr 24, 2024 · 2 comments
Open

File copy modification timestamp is off #4057

orishuss opened this issue Apr 24, 2024 · 2 comments
Labels
type:bug Something isn't working

Comments

@orishuss
Copy link

orishuss commented Apr 24, 2024

What went wrong?

When copying files, the files stats don't change as expected. The specific important stat is the date modified of the file, which is always 2020-04-16 12:00:00.000000000 +0000.

I encountered this error when go build inside a container failed due to cache problems: it thought that a file hasn't changed when in fact it has. This usually doesn't break go's build - go usually understands that the file has changed, but apparently in some cases it relies on the file's modification date.

Adding a RUN touch * line right after the copy solves the problem (and go builds successfully), as the modification & access stats change.

In the log below I ran the simple Earthfile:

VERSION --try 0.8

test:
    FROM ubuntu:22.04
    COPY file file
    RUN cat file
    RUN stat file

When running earthly -i +test twice, when changing the content of file in the middle, I'd expect that the file's modify date stat would change, but it doesn't. The "change" date changes, and I'd expect the modify date to be the same.

[I] > earthly -i +test
 Init 🚀
————————————————————————————————————————————————————————————————————————————————

           buildkitd | Found buildkit daemon as docker container (earthly-buildkitd)

 Build 🔧
————————————————————————————————————————————————————————————————————————————————

              logbus | Setting organization "" and project ""
               +test | --> FROM +base
        ubuntu:22.04 | --> Load metadata ubuntu:22.04 linux/amd64
               +test | --> FROM ubuntu:22.04
               +test | [----------] 100% FROM ubuntu:22.04
               +test | *cached* --> COPY file file
               +test | --> RUN cat file
               +test | file3
               +test | --> RUN stat file
               +test |   File: file
               +test |   Size: 6                Blocks: 8          IO Block: 4096   regular file
               +test | Device: 7ah/122d Inode: 116654190   Links: 1
               +test | Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (    0/    root)
               +test | Access: 2020-04-16 12:00:00.000000000 +0000
               +test | Modify: 2020-04-16 12:00:00.000000000 +0000
               +test | Change: 2024-04-24 07:47:14.669475735 +0000
               +test |  Birth: 2024-04-24 07:47:14.669475735 +0000
              output | --> exporting outputs

 Push Summary ⏫ (disabled)
————————————————————————————————————————————————————————————————————————————————

To enable pushing use earthly --push

 Local Output Summary 🎁
————————————————————————————————————————————————————————————————————————————————



========================== 🌍 Earthly Build  ✅ SUCCESS ==========================

🛰️ Reuse cache between CI runs with Earthly Satellites! 2-20X faster than without cache. Generous free tier https://cloud.earthly.dev
[I] > earthly -i +test
 Init 🚀
————————————————————————————————————————————————————————————————————————————————

           buildkitd | Found buildkit daemon as docker container (earthly-buildkitd)

 Build 🔧
————————————————————————————————————————————————————————————————————————————————

              logbus | Setting organization "" and project ""
               +test | --> FROM +base
        ubuntu:22.04 | --> Load metadata ubuntu:22.04 linux/amd64
               +test | --> FROM ubuntu:22.04
               +test | [----------] 100% FROM ubuntu:22.04
               +test | --> COPY file file
               +test | --> RUN cat file
               +test | file4
               +test | --> RUN stat file
               +test |   File: file
               +test |   Size: 6                Blocks: 8          IO Block: 4096   regular file
               +test | Device: 7ah/122d Inode: 116654235   Links: 1
               +test | Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (    0/    root)
               +test | Access: 2020-04-16 12:00:00.000000000 +0000
               +test | Modify: 2020-04-16 12:00:00.000000000 +0000
               +test | Change: 2024-04-24 07:48:44.893795412 +0000
               +test |  Birth: 2024-04-24 07:48:44.893795412 +0000
              output | --> exporting outputs

 Push Summary ⏫ (disabled)
————————————————————————————————————————————————————————————————————————————————

To enable pushing use earthly --push

 Local Output Summary 🎁
————————————————————————————————————————————————————————————————————————————————



========================== 🌍 Earthly Build  ✅ SUCCESS ==========================

🛰️ Reuse cache between CI runs with Earthly Satellites! 2-20X faster than without cache. Generous free tier https://cloud.earthly.dev

What earthly version?

earthly version v0.8.8

@orishuss orishuss added the type:bug Something isn't working label Apr 24, 2024
@ingwarsw
Copy link
Contributor

ingwarsw commented Apr 26, 2024

Did you tried COPY --keep-ts

See docs.
Maybe that should resolve the issue?

@orishuss
Copy link
Author

orishuss commented May 5, 2024

Yes this does the trick, thanks!
Any reason for this not to be the default behaviour? It is the default in docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants