1

I tried to test how to deploy .net core app to Heroku using this guide: https://blog.devcenter.co/deploy-asp-net-core-2-0-apps-on-heroku-eea8efd918b6

It in guide this repository is used: https://github.com/mykeels/sample-web-api , I also tried creating project myself with example API.

I always got same error:

2019-02-13T09:37:07.748661+00:00 heroku[web.1]: Starting process with command /bin/sh -c ASPNETCORE_URLS\=http://\*:\30806\ dotnet\ SampleWebApi.dll 2019-02-13T09:37:09.958842+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-13T09:37:10.034930+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-13T09:37:09.940160+00:00 heroku[web.1]: Process exited with status 145

Heroku logs

I used this Dockerfile:

FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY . .
CMD ASPNETCORE_URLS=http://*:$PORT dotnet SampleWebApi.dll

I am using published output (so it should be builded already) for image creation and pushing to Heroku. These processes are successful. I tried quite a few guides with different docker files, but in all cases I got same result. I also tried using buildpacks such as https://github.com/jincod/dotnetcore-buildpack however, none of them worked.

Is there any way to fix this crashing?

  • Possible duplicate of [dotnet aspnetcore docker build fails with a 145 error code](https://stackoverflow.com/questions/42346498/dotnet-aspnetcore-docker-build-fails-with-a-145-error-code) – DavidG Feb 13 '19 at 10:07
  • Possible duplicate of [dotnet aspnetcore docker build fails with a 145 error code](https://stackoverflow.com/questions/42346498/dotnet-aspnetcore-docker-build-fails-with-a-145-error-code) – ChrisGPT was on strike Feb 13 '19 at 13:29

1 Answers1

0

You missede build stage. Try to add this to your Dockerfile

Dockerfile

FROM microsoft/dotnet:2.1-sdk-alpine AS builder
WORKDIR /source
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -r linux-musl-x64 -o /app

FROM microsoft/dotnet:2.1-aspnetcore-runtime-alpine
WORKDIR /app
COPY --from=builder /app .
ENTRYPOINT ["dotnet", "SampleWebApi.dll"]

Also you can check my full demo project deployed to Heroku https://github.com/jincod/AspNetCoreDemoApp

jincod
  • 584
  • 4
  • 17
  • I cloned your demo, but got this error when tried to push to heroku: error MSB3073: The command "npm install" exited with code 127. – Trash Panda Feb 15 '19 at 16:43
  • Did you add node.js buildpack? Could you please attach build log? – jincod Feb 15 '19 at 17:10
  • Missed that one. Demo works fine. Thank you. Now I'll try to deploy my app and see if it works – Trash Panda Feb 15 '19 at 17:27
  • I tried to deploy asp.net core web app with api using your buildpacks and although it deployed successfully, it crashes. I only used dotnet buildpack, since I do not need node js for now. Here are the logs: – Trash Panda Feb 15 '19 at 18:35
  • 2019-02-15T18:28:20.507545+00:00 app[web.1]: Failed to load xiz, error: libunwind.so.8: cannot open shared object file: No such file or directory 2019-02-15T18:28:20.507572+00:00 app[web.1]: Failed to bind to CoreCLR at '/app/heroku_output/libcoreclr.so' 2019-02-15T18:28:33.127806+00:00 heroku[web.1]: Starting process with command `cd /app/heroku_output && ./aspnetapi` 2019-02-15T18:28:35.733291+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-15T18:28:35.710316+00:00 heroku[web.1]: Process exited with status 136 – Trash Panda Feb 15 '19 at 18:35
  • I suppose it cause target version. Use this link for buildpack https://github.com/jincod/dotnetcore-buildpack#v2.1.200 for support netcoreapp2.0. More info https://github.com/jincod/dotnetcore-buildpack/issues/44 – jincod Feb 16 '19 at 03:21