[英]How to deploy Visual Studio template for dotnet core 6 and angular to azure
[英]How to dockerize dotnet core angular template application?
我使用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秒內完成。 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:找不到/app/Web.csproj(46,5):錯誤MSB3073:命令“ npm install”以代碼127退出。命令'/ bin / sh -c dotnet publish -c Release -o out'返回非零代碼: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
請參見本博客文章了解更多詳情
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.