首页 > 解决方案 > .net core,在 docker 中运行默认的 Angular 模板

问题描述

我正在尝试将 .NET Core 3.1 中的默认角度模板作为 docker 实例运行。

我已经在不同的页面(也在这里)上读到添加以下内容就足够了。

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

但我仍然收到以下错误:

/bin/sh: 2: /tmp/tmp859332ce906f4bcaad00b1b144b3fec4.exec.cmd: npm: not found
/src/Internationaal-Dashboard/Internationaal-Dashboard.csproj(42,5): error MSB3073: The command "npm install" exited with code 127.
The command '/bin/sh -c dotnet publish "Internationaal-Dashboard.csproj" -c Release -o /app/publish' returned a non-zero code: 1

有人知道我忘记了什么。

我将在下面包含完整的 docker 文件:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
RUN apt-get update && \
    apt-get install -y wget && \
    apt-get install -y gnupg2 && \
    wget -qO- https://deb.nodesource.com/setup_14.x | bash - && \
    apt-get install -y build-essential nodejs
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Internationaal-Dashboard/Internationaal-Dashboard.csproj", "Internationaal-Dashboard/"]
RUN dotnet restore "Internationaal-Dashboard/Internationaal-Dashboard.csproj"
COPY . .
WORKDIR "/src/Internationaal-Dashboard"
RUN dotnet build "Internationaal-Dashboard.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Internationaal-Dashboard.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Internationaal-Dashboard.dll"]

标签: c#docker.net-core.net-core-3.1

解决方案


推荐阅读