I\'m attempting to dockerise my node application. My current application is a nodejs express server with postgresql. ExpressJS uses node-sass-middleware to handle the sass asset
The support for Node.js 7 (for Linux and OSX) seems to have been added in node-sass v3.7.0
. Make sure you use a version equal to or newer than this.
Either you can update your Dockerfile:
FROM node:7.2.1
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y libpq-dev postgresql-client
ENV APP_HOME /my_app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD package.json .
# Add the two entries below
RUN mkdir -p node_modules/node-sass/vendor/linux-x64-51
RUN curl -L https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-51_binding.node -o node_modules/node-sass/vendor/linux-x64-51/binding.node
RUN npm install
RUN npm rebuild node-sass
ADD . .
CMD [ "npm", "start" ]
EXPOSE 3000
Or you can download the binding locally and then build from the Dockerfile without any modification:
cd /path/to/node_app/node_modules
mkdir -p node-sass/vendor/linux-x64-51
curl -L https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-51_binding.node -o node-sass/vendor/linux-x64-51/binding.node
Keep an eye out for different versions for the pre-compiled native bindings at: https://github.com/sass/node-sass/releases