emk / heroku-buildpack-rust

A buildpack for Rust applications on Heroku, with full support for Rustup, cargo and build caching.
522 stars 186 forks source link

Remove build artifacts after the build process? #17

Closed tomaka closed 5 years ago

tomaka commented 7 years ago

Heroku has a limit of 300 MB for the slug size (ie. the output of the build process).

Unfortunately I've run into an annoying problem this morning, which is that running cargo build --release creates a target directory that weights 310 MB, though the actual binary itself is only 41 MB.

Heroku's docs suggest that you use a .slugignore file (similar to a .gitignore). However the files that match .slugignore are removed before the build process, so it's useless in my situation.

I don't know if you have a solution to suggest for me and people who run in the same situation as me? Removing the /target/release/deps in the buildpack would be nice, but as I'm not familiar with heroku's caching process I don't know if it's a good idea to do so.

emk commented 7 years ago

I'll need to look at this. Thanks for letting me know!

steveklabnik commented 7 years ago

This is hitting me today too. I think it's because this isn't properly using the cache dirs. My slugs grow and grow until they hit 300 and then fail. i have some preliminary findings here https://github.com/rust-lang-nursery/thanks/issues/31

emk commented 7 years ago

Entirely possible! A lot of this code was written for much older versions of the toolchain and it still doesn't use all the options available with the newer toolchain perfectly.

Le 25 janv. 2017 7:00 PM, "Steve Klabnik" notifications@github.com a écrit :

This is hitting me today too. I think it's because this isn't properly using the cache dirs. My slugs grow and grow until they hit 300 and then fail. i have some preliminary findings here rust-lang-nursery/thanks#31 https://github.com/rust-lang-nursery/thanks/issues/31

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emk/heroku-buildpack-rust/issues/17#issuecomment-275271270, or mute the thread https://github.com/notifications/unsubscribe-auth/AACQY1D1OP06oTwl4oCV-qK6K-tjhR-Kks5rV-H_gaJpZM4K4OG6 .

emk commented 7 years ago

Hmm. On further reflection, I think the issue here may be that we don't know the name of the built binary and so we're copying too much of target/ into the slug. I'm pretty sick this week, so I probably can't look right away.

Le 25 janv. 2017 8:33 PM, "Eric Kidd" eric@randomhacks.net a écrit :

Entirely possible! A lot of this code was written for much older versions of the toolchain and it still doesn't use all the options available with the newer toolchain perfectly.

Le 25 janv. 2017 7:00 PM, "Steve Klabnik" notifications@github.com a écrit :

This is hitting me today too. I think it's because this isn't properly using the cache dirs. My slugs grow and grow until they hit 300 and then fail. i have some preliminary findings here rust-lang-nursery/thanks#31 https://github.com/rust-lang-nursery/thanks/issues/31

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emk/heroku-buildpack-rust/issues/17#issuecomment-275271270, or mute the thread https://github.com/notifications/unsubscribe-auth/AACQY1D1OP06oTwl4oCV-qK6K-tjhR-Kks5rV-H_gaJpZM4K4OG6 .

steveklabnik commented 7 years ago

I'm pretty sick this week, so I probably can't look right away.

❤️ don't worry about it; it's easy to deal with in the meantime, and I might look too. Get better!

tomaka commented 7 years ago

it's easy to deal with in the meantime

I wonder what you mean by that. I stopped using heroku because of this issue.

steveklabnik commented 7 years ago

For me;

$ heroku plugins:install heroku-repo
$ heroku repo:purge_cache
$ heroku repo:reset
$ git push heroku master

this basically re-builds your slug from scratch. since my issue was that each build was well under 300mb, but the sum total was, this resets that and gives me more builds.

On Thu, Jan 26, 2017 at 2:41 AM, tomaka notifications@github.com wrote:

it's easy to deal with in the meantime

I wonder what you mean by that. I stopped using heroku because of this issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emk/heroku-buildpack-rust/issues/17#issuecomment-275325484, or mute the thread https://github.com/notifications/unsubscribe-auth/AABsiva_J0z01XxDu_FOwQbJFA-vTjUuks5rWE4xgaJpZM4K4OG6 .

emk commented 7 years ago

I think this is fixed by #22, which was just merged. Could somebody please try again and let me know if they encounter any problems?

emk commented 5 years ago

OK, I believe that this issue has been fixed for quite a while now, thanks to the improved target-copying code. Please reopen this if you're still seeing any problems.