How to dockerize .Net application with Angular?

Discussão em 'Angular' iniciado por Hoang Minh, Abril 10, 2025.

  1. Hoang Minh

    Hoang Minh Guest

    I recently created a .Net application with Angular and try to dockerize it. It builds successfully, but it does not launch the angular app.

    This is how I created my project:

    mkdir <solution_name>
    cd <solution_name>
    dotnet new sln --name <solution_name>
    mkdir src
    cd src
    dotnet new angular -n App
    Open <solution_name> soln
    right click, create new folder called src
    right click on src, add existing project App


    and this is how my Dockerfile looks like:

    # Stage 1: Build Angular App
    FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
    #do not install node

    # Stage 2: Build .NET Application
    FROM mcr.microsoft.com/dotnet/sdk:9.0 AS dotnet-build
    RUN apt-get update && apt-get install -y nodejs npm
    WORKDIR /src
    COPY /src/App/App.csproj .
    RUN dotnet restore
    COPY ./src/App .

    # Stage 3: Publish .Net
    FROM dotnet-build AS dotnet-publish
    RUN dotnet publish -c Release -o /app

    # Stage 4: Combine Angular and .NET for Deployment
    FROM base AS final
    WORKDIR /app
    COPY --from=dotnet-publish /app .
    ENTRYPOINT ["dotnet", "App.dll"]


    I can see that the .net application starts, but the Spa angular app does not. Can anyone tell me what I'm missing ?

    Thank you

    Continue reading...

Compartilhe esta Página