-
Notifications
You must be signed in to change notification settings - Fork 406
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
Add KO_DATA_DATE_EPOCH env var to set the modification time for files in kodata
#372
Conversation
Codecov Report
@@ Coverage Diff @@
## main #372 +/- ##
==========================================
+ Coverage 43.92% 44.04% +0.12%
==========================================
Files 33 33
Lines 1589 1605 +16
==========================================
+ Hits 698 707 +9
- Misses 764 769 +5
- Partials 127 129 +2
Continue to review full report at Codecov.
|
Nice! I really like this. I'd like to add more to the README to describe why you might want to do this, and what kinds of values you might want to give it. Depending on the use case, users might want to report a modtime of the last Git commit, or the time the image was built ( Would it make sense to have a special value for the env var that we interpret to mean "passthrough the files' actual modtimes"? (That wouldn't have to happen in this PR, just curious if it might be useful) |
Would it make sense to just use |
Hi @imjasonh and @jonjohnsonjr,
Yes, I can do that.
I am using this (fork) in a GitHub Action to deploy a api that also has some static assets. Some files are generated at build time and served directly using
For me at least, this would not make sense. Most of my builds and deploys happen in pipelines so the actual modtimes will always be the "time of checkout" in the pipeline. But maybe for users building directly on their machine this might be useful.
Yes, lets say we have a app that requires some sort of static storage (e.g. an index etc.) baked into the container. I would expect that only the modtime of the entries in the tar file of the kodata layer will be updated based on the env var the pipeline set. The pipeline could be build to detect the last modified timestamp of the input data for the index and supply that via the env var. So In this case, the amount of changes and pushes required is minimized to the one kodata layer. |
Brilliant. This makes a lot of sense. Thanks for the explanation. |
README.md
Outdated
@@ -344,6 +344,8 @@ or to the latest git commit's timestamp with: | |||
export SOURCE_DATE_EPOCH=$(git log -1 --format='%ct') | |||
``` | |||
|
|||
The same applies to `KO_DATA_DATE_EPOCH` which sets the last modified time of all files in `kodata`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a little more why this is useful (e.g. mention modtime for https://golang.org/pkg/net/http/#ServeFile)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I improved the docs a bit.
As for examples for the timestamp source I could not think of anything useful.
Maybe I could add something more complex like https://stackoverflow.com/questions/4561895/how-to-recursively-find-the-latest-modified-file-in-a-directory.
Let me know what you think.
6dbd6cb
to
46ff248
Compare
46ff248
to
1c1f3b4
Compare
Thanks! |
Example:
This allows static file servers mounted at
KO_DATA_PATH
to send theLast-Modified
header and handle revalidation requests.