dotnetcore-buildpack icon indicating copy to clipboard operation
dotnetcore-buildpack copied to clipboard

Reduce publish slug size

Open karlwancl opened this issue 8 years ago • 10 comments

@jincod As I am also having an issue of large slug size similar to #19 , I have implemented logic to reduce the slug size when publish to heroku. In my case, the slug size is reduced from 470MB to 81MB.

It is done by publishing a self-contained dotnet app instead of embedding the whole dotnet core runtime into the slug, hence the great reduction in size. See if you could accept this PR, thanks 😄

karlwancl avatar Sep 06 '17 12:09 karlwancl

Thank you for working on this! Slug size has been an issue for me as well.

stavro avatar Sep 06 '17 23:09 stavro

Hi @lppkarl

Many thanks for your contribution!

I'll review it.

jincod avatar Sep 10 '17 08:09 jincod

@lppkarl I've tried this but it still outputs a .dll (which can't be executed) - is there some additional config i need to change in my project?

chrisanderton avatar Sep 12 '17 15:09 chrisanderton

@chrisanderton Maybe you have targeted a wrong framework? The publish command generates executable (with no extension) only when you're targeting netcoreapp instead of netstandard

karlwancl avatar Sep 13 '17 05:09 karlwancl

hmm @lppkarl i'm targeting netcoreapp1.1 - but tbh i'm not so strong on dotnet - does this only work with 2.0?

chrisanderton avatar Sep 15 '17 20:09 chrisanderton

@chrisanderton As I see it, --self-contained tag only works for netcoreapp2.0, you may migrate your project from 1.1 to 2.0. See https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/ 😄

karlwancl avatar Sep 16 '17 04:09 karlwancl

@lppkarl , I'm currently using your pull request link for buildpack and it reduces my heroku app slug size from 430MB to 40MB. My app is .net core app 2.0. Great works!

toannguyen83 avatar Oct 15 '17 05:10 toannguyen83

Hi @lppkarl

Would be great to do this feature optional export SELF_CONTAINED=${SELF_CONTAINED:-false} for example. Could you please implement it?

Also I've added env var DOTNET_SKIP_FIRST_TIME_EXPERIENCE (https://github.com/jincod/dotnetcore-buildpack/blob/master/bin/compile#L28) which helps to reduce slug size.

jincod avatar Nov 12 '17 04:11 jincod

@jincod ya, I could help implement it.

I'm interested in how DOTNET_SKIP_FIRST_TIME_EXPERIENCE help reduces slug size? Is there a mechanism for heroku to cache its installation files or restored file so that the process is not done again for second time onwards?

karlwancl avatar Nov 12 '17 13:11 karlwancl

Hi @lppkarl

Thanka a lot! Ping me if you have any questions.

DOTNET_SKIP_FIRST_TIME_EXPERIENCE dotnet core cli option. You can find more info here http://www.erikschierboom.com/2017/03/21/continuous-integration-of-dotnet-core-applications/

jincod avatar Nov 12 '17 14:11 jincod