我使用 dotnet cli 角度模板创建了一个 Web 应用程序。
dotnet new anguar Web
现在我想对这个应用程序进行 dockerize。我将以下 Dockerfile 添加到项目文件夹中。
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"]
然后当我在项目文件夹中时运行以下命令。
sudo docker build -t accman-web .
但我收到以下错误:
/app/Web.csproj 的恢复在 5.01 秒内完成。
网页 -> /app/bin/Release/netcoreapp2.2/Web.dll
网页 -> /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 dotnetpublish-cRelease-oout”返回非零代码:1
我需要做什么来构建这个简单应用程序的映像?
Angular 需要 Nodejs 和 npm,但似乎缺少它们。将其添加到您的 Dockerfile 以在容器中安装 nodejs 和 npm:
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 https://www.google.com/amp/tattoocoder.com/dotnet-new-to-azure-with-docker-using-cli/amp/博客文章了解更多详细信息
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)