dotnet / dotnet-docker

Docker images for .NET and the .NET Tools.
https://hub.docker.com/_/microsoft-dotnet
MIT License
4.46k stars 1.94k forks source link

Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x #972

Closed TheRealVira closed 5 years ago

TheRealVira commented 5 years ago

Steps to reproduce the issue

I have set up an asp.net core web project - Angular - using dotnet:2.2; added "*.scss" support and added the following DOCKERFILE:

FROM microsoft/dotnet:2.2-sdk AS base

RUN apt-get update -yq \
    && apt-get install curl gnupg -yq \
    && curl -sL https://deb.nodesource.com/setup_10.x | bash \
    && apt-get install nodejs -yq

WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 32772

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["ViraOfficialWebpage/ViraOfficialWebpage.csproj", "ViraOfficialWebpage/"]
RUN dotnet restore "ViraOfficialWebpage/ViraOfficialWebpage.csproj"
COPY . .
WORKDIR "/src/ViraOfficialWebpage"
RUN dotnet build "ViraOfficialWebpage.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "ViraOfficialWebpage.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ViraOfficialWebpage.dll"]

Expected behavior

In theory my web application should be build as expected - I have also run npm rebuild node-sass, but still, no success.

Actual behavior

ERROR in ./src/app/app.component.scss
      Module build failed: Error: Missing binding /app/ClientApp/node_modules/node-sass/vendor/linux-x64-64/binding.node
      Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x

      Found bindings for the following environments:
        - Windows 64-bit with Node.js 10.x

      This usually happens because your environment has changed since running `npm install`.
      Run `npm rebuild node-sass` to download the binding for your current environment.
          at module.exports (/app/ClientApp/node_modules/node-sass/lib/binding.js:15:13)
          at Object.<anonymous> (/app/ClientApp/node_modules/node-sass/lib/index.js:14:35)
          at Module._compile (internal/modules/cjs/loader.js:701:30)
          at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
          at Module.load (internal/modules/cjs/loader.js:600:32)
          at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
          at Function.Module._load (internal/modules/cjs/loader.js:531:3)
          at Module.require (internal/modules/cjs/loader.js:637:17)
          at require (internal/modules/cjs/helpers.js:22:18)
          at Object.sassLoader (/app/ClientApp/node_modules/sass-loader/lib/loader.js:24:22)

Output of docker version

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:31 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info

Containers: 44
 Running: 38
 Paused: 0
 Stopped: 6
Images: 75
Server Version: 18.09.2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d5c963d
ID: Z5HE:STOL:JZCQ:C66L:YSWS:L73E:ZPEI:IDRV:JOK3:ZWWH:IHOT:6RJN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 125
 Goroutines: 126
 System Time: 2019-03-07T17:05:14.2663219Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
MichaelSimons commented 5 years ago

@TheRealVira - Without seeing your project, I am not following where the dependency on Node comes from. One thing I did noticed is that in your base stage, you are installing node but I am not seeing any usage of this stage. What is the intended usage of this stage?

TheRealVira commented 5 years ago

@MichaelSimons I am using Node based on the Angular dependency. Our project can be found inside the following repository: https://github.com/vira-software-solutions/vira-offical-website

You should also be able to build the angular project without the .Net Core dependencies, since it is a client side web-app.

mthalman commented 5 years ago

@TheRealVira - I forked your repo and was able to get the image built and verify the app runs without ever encountering the error you're seeing. I made some slight tweaks to the Dockerfile you provided to target our MCR-hosted images and reference the "base" phase image from build in order to have npm available. You can see my changes at https://github.com/mthalman/vira-offical-website.

MichaelSimons commented 5 years ago

Closing as @mthalman provided a working solution.