Hi there,
I am struggling trying to run the template application inside Docker.
Looks to me that JavaScriptServices can't find nodejs on the docker image microsoft/aspnetcore:1.1
I get the error "An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.ni.dll but was not handled in user code"
I tried to modify the Dockerfile adding nodejs the following way:
FROM microsoft/aspnetcore:1.1
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm
node as nodejsRUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "MyApp.dll"]
Still without success.
Using the following dockerfile works (because the docker image has nodejs installed):
FROM microsoft/aspnetcore-build
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "MyApp.dll"]
I just think it is overkill to have this 1.19GB image (compared to 268 MB from aspnetcore) just to run the aspnetcore + nodejs.
Would it be possible to create a sample application where Docker is working?
+1
What a coincidence. I was troubleshooting the exact same issue. As Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo) refers to node by processname 'node', the Exception is thrown.
The following worked for me:
FROM microsoft/dotnet:1.1-sdk-msbuild
RUN apt-get update
RUN wget -qO- https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y build-essential nodejs
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
CMD ["dotnet", "run", "--server.urls", "http://0.0.0.0:5000"]
Note that it was also necessary to modify Program.cs, adding .UseUrls("http://0.0.0.0:5000") before .Build().
I just think it is overkill to have this 1.19GB image (compared to 268 MB from aspnetcore) just to run the aspnetcore + nodejs.
If you find a more compact way to do it, please let us know - we can then add it to the wiki page here for others who are also interested in using Docker with this.
BTW nothing in this setup is specific to VS2017. If you're trying to enable a special VS2017 feature, I'm afraid that's outside my area of expertise.
Most helpful comment
The following worked for me:
Note that it was also necessary to modify
Program.cs, adding.UseUrls("http://0.0.0.0:5000")before.Build().If you find a more compact way to do it, please let us know - we can then add it to the wiki page here for others who are also interested in using Docker with this.
BTW nothing in this setup is specific to VS2017. If you're trying to enable a special VS2017 feature, I'm afraid that's outside my area of expertise.