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 modification time are changed after application is copied to /app #386

Open
jxltom opened this issue Sep 11, 2018 · 8 comments
Open

Comments

@jxltom
Copy link

jxltom commented Sep 11, 2018

Currently after coping application to /app during building in herokuish, original file modification time are all lost and time for coping will be used.

This may cause issue when running some commands in custom buildpack. Such as in default python buildpack, collectstatic command will be run and this command should collect static files which modificaiton time are older than existed ones.

But since original file modification time are lost, this command will collect all static files no matter they have been collected before or not.

Can we keep original file modification time during buidling, such as using cp -p?

@josegonzalez
Copy link
Member

Do you mean here? If so, does mv have a preserve-timestamps property?

Also, I'm not really sure as to what collectstatic is supposed to do based on what you're saying. Like, what is a potential use case of that?

@jxltom
Copy link
Author

jxltom commented Sep 12, 2018

I'm not so sure, Maybe it is here?

cp -r "$app_path/." "$build_path"

But I can confirm that the modified time have already been changed in /bin/compile process such as in python's buildpack as following.

https://github.com/heroku/heroku-buildpack-python/blob/0fe4f91395c1498dc97124d8606a65558009ab93/bin/compile#L315-L322

@josegonzalez
Copy link
Member

We could try -p on that too.

@jxltom
Copy link
Author

jxltom commented Sep 12, 2018

It looks like mv does not have a -p option, but maybe we could also use cp -p but delete original files.

@jxltom
Copy link
Author

jxltom commented Sep 12, 2018

The collectstatic command in python's django framework is used for collecting static files for web applications and then upload to remote/local storage which can be used for static file serving such as for nginx. This command won't collect static files which modified time are older than the existed ones (This means the files are not modified and shouldn't be re-collected/uploaded). The problem here is herokuish will fresh the modified time all the time and so collectstatic will always collect/upload all the static files even they are not modified. This slows down the deploy process and should not be neccessary.

So could we keep the original modified time for our applications during building? Thanks.

@josegonzalez
Copy link
Member

Thanks for the explanation.

Is this verified to not be the case - the collectstatic affecting old assets - on Heroku? Or do you have the same issue with your app? If you can validate that on Heroku (please gist the output) that would be helpful.

I'd be happy to take a PR if we can verify the above.

@jxltom
Copy link
Author

jxltom commented Sep 13, 2018

This is verified to not be the case on heroku. Here is the gist. I deployed same application both in heroku and in dokku. https://gist.github.com/jxltom/2896f8f3b7b024a07caad5bd06c7a888

Note that in dokku, https://gist.github.com/jxltom/2896f8f3b7b024a07caad5bd06c7a888#file-deploy-by-dokku-L219, all 579 static files copied by collectstatic but in heroku, https://gist.github.com/jxltom/2896f8f3b7b024a07caad5bd06c7a888#file-deploy-by-heroku-L204, only 431 static files copied but 148 unmodified since their modified time are not changed.

@josegonzalez
Copy link
Member

Pull requests welcome, though I wonder if a cp vs a mv has any impact on the build time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants