Reduce publish slug size#20
Reduce publish slug size#20karlwancl wants to merge 1 commit intojincod:masterfrom karlwancl:feature_reduce_slug_size
Conversation
|
Thank you for working on this! Slug size has been an issue for me as well. |
bin/compile
Outdated
| PROJECT_NAME=$(basename ${PROJECT_FILE%.*}) | ||
|
|
||
| echo "restore ${PROJECT_FILE}" | ||
| dotnet restore $PROJECT_FILE --runtime linux-x64 |
There was a problem hiding this comment.
Removed dotnet restore here because dotnet restore is now an implicit command, dotnet publish internally calls dotnet restore, no needs explicit call anymore.
Reference: dotnet/announcements#23
|
|
||
| cat << EOT >> ${BUILD_DIR}/Procfile | ||
| web: cd \$HOME/heroku_output && ASPNETCORE_URLS='http://+:\$PORT' dotnet "./${PROJECT_NAME}.dll" --server.urls http://+:\$PORT | ||
| web: cd \$HOME/heroku_output && chmod +x ${PROJECT_NAME} && ASPNETCORE_URLS='http://+:\$PORT' ./${PROJECT_NAME} --server.urls http://+:\$PORT |
There was a problem hiding this comment.
Add chmod +x here because the executable generated from dotnet publish does not have "x" permission
Reference: dotnet/sdk#1331
|
Hi @lppkarl Many thanks for your contribution! I'll review it. |
|
@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 Maybe you have targeted a wrong framework? The publish command generates executable (with no extension) only when you're targeting netcoreapp instead of netstandard |
|
hmm @lppkarl i'm targeting netcoreapp1.1 - but tbh i'm not so strong on dotnet - does this only work with 2.0? |
|
@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/ 😄 |
|
@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! |
|
Hi @lppkarl Would be great to do this feature optional Also I've added env var |
|
@jincod ya, I could help implement it. I'm interested in how |
|
Hi @lppkarl Thanka a lot! Ping me if you have any questions.
|
@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 😄