如何docker dotnet核心角度模板应用程序? [英] How to dockerize dotnet core angular template application?

查看:49
本文介绍了如何docker dotnet核心角度模板应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用dotnet cli角度模板创建了一个Web应用程序.

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

dotnet new anguar Web

现在,我想对这个应用程序进行docker化.我将以下Dockerfile添加到项目文件夹中.

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 .

但是我遇到以下错误:

对于/app/Web.csproj,恢复已在5.01秒内完成.Web->/app/bin/Release/netcoreapp2.2/Web.dllWeb->/app/bin/Release/netcoreapp2.2/Web.Views.dll/bin/sh:2:/tmp/tmpa49d981806144cfd8e2cbdde42404952.exec.cmd:npm:找不到/app/Web.csproj(46,5):错误MSB3073:命令"npm install"退出,代码为127.命令'/bin/sh -c dotnet publish -c Release -o out'返回非零代码:1

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?

推荐答案

对于Angular,您似乎需要nodejs和npm,这似乎已经丢失了.将此添加到您的Dockerfile中以在容器中安装nodejs和npm:

You need nodejs and npm for Angular, which seems to be missing. Add this to your Dockerfile to install nodejs and npm in the container:

RUN apt-get update && \
    apt-get install -y wget && \
    apt-get install -y gnupg2 && \
    wget -qO- https://deb.nodesource.com/setup_6.x | bash - && \
    apt-get install -y build-essential nodejs

请参见博客文章以获取更多详细信息

See this blog post for more details

这篇关于如何docker dotnet核心角度模板应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆