Home:ALL Converter>How to dockerize dotnet core angular template application?

How to dockerize dotnet core angular template application?

Ask Time:2019-06-29T03:30:10         Author:xkcd

Json Formatter

I created a web application using the dotnet cli angular template.

dotnet new anguar Web

Now I want to dockerize this application. I added the following Dockerfile to the project folder.

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Web.dll"]

And then run the following command when I am in the project folder.

sudo docker build -t accman-web .

But I am getting the following error:

Restore completed in 5.01 sec for /app/Web.csproj. Web -> /app/bin/Release/netcoreapp2.2/Web.dll Web -> /app/bin/Release/netcoreapp2.2/Web.Views.dll /bin/sh: 2: /tmp/tmpa49d981806144cfd8e2cbdde42404952.exec.cmd: npm: not found /app/Web.csproj(46,5): error MSB3073: The command "npm install" exited with code 127. The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1

What do I have to do to build the image of this simple application?

Author:xkcd,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56812316/how-to-dockerize-dotnet-core-angular-template-application
yy