Base solution for your next web application
Open Closed

Angular/ .net core Create Docker image using docker file #8914


User avatar
0
Suretys created

Hello,

i am using docker file to create image, we do not need build.ps file. need to only .net api is running in docker image. you can see my docker file.this file is in host project. image is not working server is not responding. give me 500 error " internal server error". when i call any api using swagger.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["src/Suretys.Portal.Web.Host/Suretys.Portal.Web.Host.csproj", "src/Suretys.Portal.Web.Host/"] COPY ["src/Suretys.Portal.Web.Core/Suretys.Portal.Web.Core.csproj", "src/Suretys.Portal.Web.Core/"] COPY ["src/Suretys.Portal.GraphQL/Suretys.Portal.GraphQL.csproj", "src/Suretys.Portal.GraphQL/"] COPY ["src/Suretys.Portal.Application.Shared/Suretys.Portal.Application.Shared.csproj", "src/Suretys.Portal.Application.Shared/"] COPY ["src/Suretys.Portal.Core.Shared/Suretys.Portal.Core.Shared.csproj", "src/Suretys.Portal.Core.Shared/"] COPY ["src/Suretys.Portal.Core/Suretys.Portal.Core.csproj", "src/Suretys.Portal.Core/"] COPY ["src/Suretys.Portal.EntityFrameworkCore/Suretys.Portal.EntityFrameworkCore.csproj", "src/Suretys.Portal.EntityFrameworkCore/"] COPY ["src/Suretys.Portal.Application/Suretys.Portal.Application.csproj", "src/Suretys.Portal.Application/"] RUN dotnet restore "src/Suretys.Portal.Web.Host/Suretys.Portal.Web.Host.csproj" COPY . . WORKDIR "/src/src/Suretys.Portal.Web.Host" RUN dotnet build "Suretys.Portal.Web.Host.csproj" -c Release -o /app/build

FROM build AS publish RUN dotnet publish "Suretys.Portal.Web.Host.csproj" -c Release -o /app/publish

FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Suretys.Portal.Web.Host.dll"]

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Suretys,

    Did you check the logs in your docker container ? Probably logs will tell you the exact problem.

  • User Avatar
    0
    Suretys created

    Hello alirizaadiyahsi,

    Can you share dockerfile which is create an only api project image not angular project.

    Thnaks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can take a look at https://github.com/aspnetzero/aspnet-zero-core/pull/3148. It is not merged yet but it works.