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
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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.