Docker Container for .NET 8 Web API Fails When Deployed to Azure Container Registry (ACR)

  Kiến thức lập trình

I’m working on a .NET 8 web api and using Docker to containerize it. The app works on my local machine, but fails when deployed to ACR. Before that I was running the app on .NET 7, and there were no issues with deploying it to ACR.

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyProject.API/MyProject.API.csproj", "MyProject.API/"]
COPY ["MyProject.Core/MyProject.Core.csproj", "MyProject.Core/"]
COPY ["MyProject.Models/MyProject.Models.csproj", "MyProject.Models/"]
RUN dotnet restore "MyProject.API/MyProject.API.csproj"
COPY . .
WORKDIR "/src/MyProject.API"
RUN dotnet build "MyProject.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyProject.API.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.API.dll"]

Any help will be appreciated, thanks in advance!

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT