aspnet / aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
https://asp.net
719 stars 171 forks source link

JavascriptServices need nodeJS on aspnetcore image #347

Closed AdnanCukur closed 6 years ago

AdnanCukur commented 6 years ago

So i can't use the lighter aspnetcore image for my website because I render parts of the javascript on the serverside with Javascriptservices and aspnet-prerendering. Right now I am forced to use the aspnetcore-build as my runtime image since it contains nodejs.

Steps to reproduce the issue

  1. Use Javascriptservices to prerender javascript
  2. Site crasches

Expected behavior

Site can render javascript with node

Actual behavior

Site crashes

Win32Exception: No such file or directory
System.Diagnostics.Process.ResolvePath(string filename)

InvalidOperationException: 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.

[2] See the InnerException for further details of the cause.
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
natemcmaster commented 6 years ago

As a workaround, you could install NodeJS into your image by adding this to your dockerfile.

ENV NODE_VERSION 6.11.3
ENV NODE_DOWNLOAD_URL https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz
ENV NODE_DOWNLOAD_SHA 610705D45EB2846A9E10690678A078D9159E5F941487ACA20C6F53B33104358C

RUN curl -SL "$NODE_DOWNLOAD_URL" --output nodejs.tar.gz \
    && echo "$NODE_DOWNLOAD_SHA nodejs.tar.gz" | sha256sum -c - \
    && tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 \
    && rm nodejs.tar.gz \
    && ln -s /usr/local/bin/node /usr/local/bin/nodejs
natemcmaster commented 6 years ago

We discussed as a team. This isn't something we are planning to change. Although we don't have a good way to measure this, we suspect that most users do not need NodeJS in the runtime image. We want to keep our images slim, and we don't believe it is overly difficult for a user to add NodeJS on their own into the runtime image. (See previous comment). We'll work on adding this to our samples. See https://github.com/aspnet/Docs/issues/5450

andreujuanc commented 6 years ago

@natemcmaster I understand you want to keep images slim as possible. But who does front end development without node pipeline of some sort?

At least there should be some official documentation pointing to the right direction. IMHO.

natemcmaster commented 6 years ago

@andreujuanc our docs are open source and we'd be happy to take contributions to address this gap. See ongoing discussion here: https://github.com/aspnet/Docs/issues/5450