.net - 如何使生产就绪 Angular Dotnet Core Docker 应用程序
问题描述
我们正在尝试制作一个具有 .Net App Server 和 Angular 客户端的 Docker 容器
项目的结构是 ReportBackEnd/ -some default .net core dirs/ - angular/
我们创建了以下 Docker 文件
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
# Setup NodeJs
RUN apt-get update -qq && \
apt-get install -qq -y wget && \
apt-get install -qq -y gnupg2 && \
wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -qq -y build-essential nodejs && \
apt-get install -qq -y nginx
# End setup
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
# Setup NodeJs
RUN apt-get update -qq && \
apt-get install -qq -y wget && \
apt-get install -qq -y gnupg2 && \
wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -qq -y build-essential nodejs && \
apt-get install -qq -y nginx
# End setup
WORKDIR /src
COPY ["ReportBackEnd.csproj", "ReportBackEnd/"]
RUN dotnet restore "ReportBackEnd/ReportBackEnd.csproj"
COPY ["angular/package.json", "ReportBackEnd/angular/"]
RUN cd ReportBackEnd/angular \
&& npm i --silent
COPY . ./
WORKDIR /src/ReportBackEnd
RUN dotnet build "ReportBackEnd.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "ReportBackEnd.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ReportBackEnd.dll"]
从 Visual Studio 的 Docker 按钮运行此文件按预期工作。
但是,当我们尝试自己构建并运行它时,我们会得到:
程序不包含适用于入口点的静态“Main”方法
我们使用的命令是:
docker build -f "C:\<dirs>\ReportBackEnd\Dockerfile" -t core:dev --target base
docker run -dt -p 80:80 core:dev
解决方案
推荐阅读
- c++ - GL_TEXTURE_2D_MULTISAMPLE 未在此范围内声明 OpenGL 4.6
- windows - 如何在 Windows 上使用 Fiddler 监控 docker push 生成的 HTTP 流量?
- excel - excel日期格式不起作用mm / dd / yyyy到yyyy-mm-dd
- winapi - 为什么 MediaFoundation 的 MediaEngine 可能会在第二次调用播放时播放视频,而不是第一次?
- node.js - 在运行 HTTPS 的 IIS 上运行 Nodejs 和 React 时遇到问题
- sql - SSMS 和 VBA 之间的存储过程结果不同
- javascript - Shopify 主题和第三方主题中使用了哪个 Javascript 框架?
- javascript - 尝试在Javascript中将对象添加到数组
- javascript - 如何从浮点数中提取单个数字
- javascript - 从 React Js 中的 Hook Modal 调用函数