Question

Trying to deploy .Net Api via Dockerfile, one project works, the other project fails at deploy with no real error ...

I followed the tutorial at: https://github.com/creativefisher/aspnetcoresample, and I was able to get it running after changing the Dockerfile to have the most recent .Net versions. It can be seen running here: https://octopus-app-ykoiy.ondigitalocean.app/

Once that was done, I decided to create a totally new project using Visual Studio 2022, .Net 7 Web Api, just the generic shell component with Docker support. It runs fine locally.

When I try to deploy this one however, it builds but fails the deploy stage.

The only output for the Deploy Log is:

[2023-06-20 17:30:15] info: Microsoft.Hosting.Lifetime[14]
[2023-06-20 17:30:15]       Now listening on: http://[::]:80
[2023-06-20 17:30:15] info: Microsoft.Hosting.Lifetime[0]
[2023-06-20 17:30:15]       Application started. Press Ctrl+C to shut down.
[2023-06-20 17:30:15] info: Microsoft.Hosting.Lifetime[0]
[2023-06-20 17:30:15]       Hosting environment: Production
[2023-06-20 17:30:15] info: Microsoft.Hosting.Lifetime[0]
[2023-06-20 17:30:15]       Content root path: /app
[]

Digital Ocean merely states “<project> failed to deploy.”

I am a Dockerfile neophyte and not sure how to solve this. The interesting thing is that when I run the code local, using docker, the messages above are exactly what the docker image has in it while it is running, as it that seems to be it’s natural “running” state.

The docker file is here, it was auto generated by Visual Studio, but it looks more or less like the version from the tutorial, save the project names are different.

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["project-luna-api-net.csproj", "."]
RUN dotnet restore "./project-luna-api-net.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "project-luna-api-net.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "project-luna-api-net.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "project-luna-api-net.dll"]

Any ideas? I would much prefer to be using .Net API as opposed to expressjs api!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 28, 2023

Hi there,

It sounds like that your App Platform health checks might be failing.

As far as I can see from the output that you’ve shared, your app is only listening on port 80 but you have EXPOSE 443 in your Dockerfile as well.

I would recommend removing the EXPOSE 443 and only leaving the EXPOSE 80 in there as this is what your app is actually listening on.

After that, make sure that your health check is configured to check for TCP connections on port 80 rather than 443 as well.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel