【发布时间】:2018-01-23 19:37:29
【问题描述】:
在创建新的 ASP.NET Core MVC 应用程序时使用什么正确的 Docker 映像,特别是使用 React/Redux(或其他需要的 Node.js)模板?如果不是特定的图像,对于由 ASP.NET Core MVC 支持的 Node.js 应用程序,Dockerfile 中应遵循哪些命令或过程?
除了运行支持 MVC 站点之外,我不需要框架的 SDK 版本。
dotnet new reactredux
运行时镜像没有安装Node.js,尝试运行容器时会报错。
Dockerfile:
FROM microsoft/aspnetcore:latest
ARG source=./bin/Debug/netcoreapp2.0/publish/
WORKDIR /app
COPY $source .
EXPOSE 80
ENTRYPOINT ["dotnet", "Project.dll"]
错误:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Make sure the Node executable is in one of those directories, or update your PATH.
我正在处理的项目正在从 ASP.NET MVC for .NET Standard 1.1(独立)升级到新的 .NET Standard 2.0 React/Redux 项目。
【问题讨论】:
-
我假设您的 API 有一个 .NET Core 后端,并且 index.html 由 Express 之类的 Node 服务提供服务?
-
更好的方法是为每个容器(Node.js 和 ASP.NET Core)启动 2 个容器,并让它们通过 docker 网络进行通信。
-
@Brad 是的,但为了示例,我使用了
dotnet new reactredux模板,它创建了一个 ASP.NET MVC 应用程序,其中默认路由为 React 应用程序提供服务。 -
@JanshairKhan 同意,但我想通过
dotnet new template让它“开箱即用”运行。 -
答案被标记为重复,但我发现它对解决这个问题更有帮助,而这里的答案让我感到困惑:stackoverflow.com/questions/45880460/…
标签: node.js docker asp.net-core asp.net-core-mvc .net-core