【发布时间】:2018-09-13 14:18:03
【问题描述】:
我收到 Heroku 警告,说我的 slug 太大了:
-----> Compressing...
Done: 304.9M
-----> Launching...
! Warning: Your slug size exceeds our soft limit (304 MB) which may affect boot time.
如何减小蛞蝓大小?这是一个 .NET Core 2.1.401 和 Angular 6 应用程序,所以我使用以下构建包:
- dotnetcore-buildpack;
- heroku-nodejs
- heroku-buildpack-apt
运行 heroku run "du . -h --max-depth=3 --threshold=1M" 会产生以下结果:
2.5M ./App/obj
524M ./App/ClientApp/node_modules
16M ./App/ClientApp/dist
9.4M ./App/ClientApp/src
549M ./App/ClientApp
2.5M ./App/bin/Release
3.3M ./App/bin
556M ./App
16M ./heroku_output/ClientApp/dist
16M ./heroku_output/ClientApp
130M ./heroku_output
189M ./.heroku/dotnet/sdk
140M ./.heroku/dotnet/shared
329M ./.heroku/dotnet
27M ./.heroku/node/lib
3.0M ./.heroku/node/include
34M ./.heroku/node/bin
63M ./.heroku/node
391M ./.heroku
11M ./.apt/usr/lib
3.3M ./.apt/usr/include
15M ./.apt/usr
15M ./.apt
1.1G .
批量为node_modules/ (524M)、./heroku/dotnet/ (329M) 和./heroku_output (130M)。
我认为我不能使用.slugignore 文件,因为构建过程需要node_modules 文件夹,所以我尝试在应用程序的@ 中使用此条目删除dotnet publish 之后的node_modules/ 文件夹987654334@,但它并没有减少 slug 的大小。
<Target Name="CleanupNodeModules" AfterTargets="Publish">
<Exec WorkingDirectory="$(SpaRoot)" Command="rm -rf node_modules" Condition=" '$(OS)' != 'Windows_NT' " ConsoleToMSBuild="true" />
</Target>
有什么想法吗?
【问题讨论】:
标签: heroku heroku-nodejs