具有Docker中JavaScriptServices的ASP.NET核心项目无法启动节点

时间:2017-11-17 15:17:50

标签: asp.net docker asp.net-core

我在让站点在docker容器内正常运行时遇到问题。容器构建良好并运行,但是当导航到页面时,它无法加载JavaScript服务。

这是Dockerfile

FROM microsoft/aspnetcore-build:2.0 AS builder
WORKDIR /app

ADD company_cas.pem /usr/local/share/ca-certificates/company_cas.crt
RUN update-ca-certificates

COPY company_cas.pem ./
RUN npm config set cafile company_cas.pem

# Run NPM install for dependencies
COPY package.json ./
RUN npm install

# 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 microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=builder /app/out .
ENTRYPOINT ["dotnet", "web.dll"]

我正在使用microsoft/aspnetcore-build:2.0基本图像,并且npm确实运行,因此我已尽可能安装了Node。

失败请求的输出是 -

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
web   |       An unhandled exception has occurred: Failed to start Node process. To resolve this:.
web   |       
web   |       [1] Ensure that Node.js is installed and can be found in one of the PATH directories.
web   |           Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
web   |           Make sure the Node executable is in one of those directories, or update your PATH.
web   |       
web   |       [2] See the InnerException for further details of the cause.
web   | System.InvalidOperationException: Failed to start Node process. To resolve this:.
web   | 
web   | [1] Ensure that Node.js is installed and can be found in one of the PATH directories.
web   |     Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
web   |     Make sure the Node executable is in one of those directories, or update your PATH.
web   | 
web   | [2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: No such file or directory

Full Error Stack @ Pastebin

这是为ASP.NET设置新的PATH以查找Node吗?如果是这样,有什么想法在Docker中应该是什么路径?

1 个答案:

答案 0 :(得分:1)

我想我忽略了运行时图像库容器。

更改为FROM microsoft/aspnetcore-build:2.0,现在我很好。