npm install error with docker - kurento application - node.js

I am trying to install a kurento webserver in docker container.
And trying to execute the kurento one to one call tutorial.
I am getting a error during the step npm install.
Step:
RUN cd kurento-tutorial-node/kurento-one2one-call && npm install
Error is as follows:
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11
gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:63:16)
gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:72:29)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:81:16
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack at Object.oncomplete (fs.js:108:15)
gyp ERR! System Linux 3.13.0-32-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /kurento-tutorial-node/kurento-one2one-call/node_modules/ws/node_modules/utf-8-validate
gyp ERR! node -v v0.10.46
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
Some one help me with the same.
Docker file is as follows:
FROM ubuntu:14.04
MAINTAINER USER1 "muraliselva.10#gmail.com"
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update
RUN apt-get install wget -y
RUN apt-get install git -y
RUN apt-get install curl -y
RUN echo "deb http://ubuntu.kurento.org trusty kms6" | sudo tee /etc/apt/sources.list.d/kurento.list
RUN wget -O - http://ubuntu.kurento.org/kurento.gpg.key | sudo apt-key add -
RUN apt-get update -y
RUN apt-get install kurento-media-server-6.0 -y
RUN sudo service kurento-media-server-6.0 start
RUN sudo service kurento-media-server-6.0 stop
RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
RUN sudo apt-get install -y nodejs -y
RUN sudo npm install -g bower -y
RUN git clone https://github.com/Kurento/kurento-tutorial-node.git
RUN cd kurento-tutorial-node/kurento-one2one-call && pwd
RUN cd kurento-tutorial-node/kurento-one2one-call && git checkout 6.5.0
RUN sudo service kurento-media-server-6.0 start
RUN cd kurento-tutorial-node/kurento-one2one-call && npm install
EXPOSE 8443
Some one help me with fixing the error.

Node version in standard Ubuntu 14.04 packages is pretty old (0.10). Use the installation instructions from the nodejs web page instead.
You can also choose to build your container FROM a node image, and then install Kurento and the kurento one-to-one tutorial on top of that. However, take into account that running several processes within a container can be cumbersome and error prone. Specially when some of the processes are run as services. There are instructions on the official Docker documentation on how to achieve that using Supervisor.

Related

NodeJS installing on Docker

I am trying to run my app on the Docker. One of the library I am using is https://www.npmjs.com/package/odbc.
In order to install that lib I need to meet the requirements described in the odbc readme:
unixODBC binaries and development libraries for module compilation
on Ubuntu/Debian sudo apt-get install unixodbc unixodbc-dev
on RedHat/CentOS sudo yum install unixODBC unixODBC-devel
odbc drivers for target database
properly configured odbc.ini and odbcinst.ini.
As per Microsoft doc in order to install ODBC Driver 13 for SQL Server https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017#ubuntu-1604-1
I manage to install all the stuff locally on my Mac and successfully connect with the SQL Server on Azure but still have some issues with installing them on the Docker and then run on VSTS.
My Dockerfile:
FROM ubuntu:16.04
USER root
RUN apt-get update
RUN apt-get install --yes curl
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
RUN apt-get install -y npm
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get install -y build-essential
RUN apt-get install -y make
RUN apt-get install apt-transport-https
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev
ADD . /var/www/app
WORKDIR /var/www/app
RUN npm install && \
npm cache clean --force
RUN npm run build
EXPOSE 3000:80
CMD ["npm", "start"]
But so far have an issue with installing NodeJS in line with
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
error: /bin/sh: 1: sudo: not found
I was trying to install only the driver and for installing NodeJs just use some existing Docker images:
FROM ubuntu:16.04
USER root
RUN apt-get update
RUN apt-get install --yes curl
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get install -y build-essential
RUN apt-get install -y make
RUN apt-get install apt-transport-https
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev
FROM node:9-alpine
ADD . /var/www/app
WORKDIR /var/www/app
RUN npm install && \
npm cache clean --force
RUN npm run build
EXPOSE 3000:80
But that approach throws an error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:170:21)
gyp ERR! System Linux 4.9.125-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /var/www/app/node_modules/odbc
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! odbc#1.4.5 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the odbc#1.4.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-03-08T20_51_17_496Z-debug.log
You are working off the ubuntu:16.04 image, and essentially doing a lot of footwork that the NodeJS guys have already done.
I would go for the image node:10-stretch-slim if I was you. And then install the drivers that you need with apt-get (if available, otherwise script the download and install in your Dockerfile).
The sudo command is not typically installed on docker images, because the user is root by default in the container sessions. If you see any errors concerning sudo, you can generally just remove sudo from the command line that is causing the issue.
Possible solution
Updating my answer here, with a possible solution for you.
This solution will put your application in a node 10 image, based on debian stretch 9. It will get the database drivers for you, from the debian 9 microsoft repository, and install all the packages that I see you are requiring from your question.
I have also added an ENTRYPOINT and CMD in the bottom of the script. But those lines are guesswork, since your question states nothing about how you actually start your application. (If you add that, then I will update my answer).
Note. Notice that I am passing --host 0.0.0.0 to the npm run start command. This is to avoid binding the live server to localhost, which will make in inaccessible from outside the container. Unless you start the container with --network="host".
You may have another means of starting your application that is more "production grade" than the live development server. If so, just replace the lines in the bottom of the Dockerfile, or ask me on this answer.
Dockerfile
# from debian stretch 9.8, node 10
FROM node:10-stretch-slim
# get apt-transport-https, etc., so that we can install by https protocol
RUN apt-get update \
&& apt-get install -y \
apt-transport-https \
build-essential \
make
# add and accept the microsoft signature
RUN curl -q https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# retrieve the microsoft packagelist for debian 9
RUN curl -q https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install the ms odbc sql driver and unixodbc header stuff
RUN apt-get update \
&& ACCEPT_EULA=Y apt-get install -y \
msodbcsql17 \
unixodbc-dev \
&& rm -rf /var/lib/apt/lists
# expose port 80 in containers of this image
EXPOSE 80
# copy working directory into the image and set as pwd
ADD . /var/www/app
WORKDIR /var/www/app
# install dependencies for the application
RUN npm install \
&& npm cache clean --force
# build the application
RUN npm run build
# i am just guessing how you want your app started here, npm?
ENTRYPOINT ["npm"]
# and then this, which makes "npm run start --host 0.0.0.0"
CMD ["run", "start", "--host", "0.0.0.0"]
Build the image with:
docker build -t mynodeapp:0.1 .
Run the application image with:
docker run -p 3000:80 --name mynodeapp mynodeapp:01
Finally visit: http://localhost:3000 to see it working.

gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/project_name/node_modules/node-sass/build'

I'm deploying an Angular project on Ububtu 16.04 and get these errors when I run sudo npm install. (won't work without sudo). It seems that npm doesn't have permission to install. I recently updated to nodejs to 8.11.4 and still have the same error so it wasn't a version problem apparently. How can I give it the correct permissions?
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/project_name/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-1065-aws
gyp ERR! command "/usr/local/bin/node" "/var/www/project_name/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "-libsass_library="
gyp ERR! cwd /var/www/front-stormsensor/node_modules/node-sass
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
Is there something off within my project? Or an incorrect installation? Not sure where to go from here, thank you
try the following command
sudo npm i --unsafe-perm
if it doesn't work try the following
sudo rm -rf ~/.node-gyp
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i --unsafe-perm
I fixed it by run this command.
sudo npm i --unsafe-perm
In case you're installing something globally, you can use:
$ sudo npm install -g <package> --unsafe-perm
use following command to install
sudo npm install --unsafe-perm=true --allow-root
This solution from jnambiar worked for me.
My OS is OSX 10.11.6.
It's basically permissions issue.
sudo rm -rf ~/.node-gyp
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i --unsafe-perm
Above set of commands helped me resolve the issue.
I am posting this to approve the set of commands which worked for me while I struggled to install the node-sass package for 2 days.
For anyone that might still have this problem, I solved it by following the suggestion of the second comment above and logging in as the root user on my ubuntu instance, as described in the second answer on this question here.. That allowed me to npm install without errors.
I used yarn instead of npm and it worked
npm permissions are quite a headache. The above solutions didn't work on my machine. Yarn did the trick.
sudo npm i yarn -g
yarn add
This command worked for me on windows.. sudo npm install --unsafe-perm

Dockerhub automated build failing due to npm install bcrypt issue

I've got a Dockerfile that looks like so:
FROM ubuntu:14.04
MAINTAINER Firstname Lastname <email#myapp.com>
ENV NODE_ENV production
ENV PORT 3333
RUN apt-get update && apt-get install -y git nodejs npm htop
RUN mkdir /root/.ssh/ && \
touch /root/.ssh/known_hosts && \
ssh-keyscan github.com >> /root/.ssh/known_hosts
ADD .ssh/my-github-deploy-key /root/.ssh/my-github-deploy-key
ADD .ssh/config /root/.ssh/config
RUN chmod 600 /root/.ssh/my-github-deploy-key && \
chmod 600 /root/.ssh/config && \
chown -R root:root /root/.ssh
RUN mkdir /srv/MyAppName && \
cd /srv && \
git clone git#github.com:MyAccountName/MyAppName.git MyAppName && \
cd MyAppName && \
npm install
EXPOSE 3333
CMD ["nodejs","/srv/MyAppName/index.js"]
And I've got my Dockerhub repo wired up to my Github repo so that an Automated Build is triggered each time I push to my master branch.
But the build is failing, and it's likely due to the npm install bcrypt command. I get the following error in the build log:
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
Error: `gyp` failed with exit code: 1 at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)
ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
ERR! System Linux 3.14.27
ERR!command "nodejs" "/usr/bin/node-gyp" "rebuild"
ERR! cwd /srv/MyApp/node_modules/bcrypt
ERR! node -v v0.10.25
ERR! node-gyp -v v0.10.10
ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
I'm not sure why this would be a legacy binary node issue since I'm installing the latest version.
How do I work around this?
Figured this out. It was a nodejs legacy issue. Needed to add the Debian nodejs-legacy symlink package like so:
RUN apt-get update && apt-get install -y git nodejs npm htop nodejs-legacy
And then the build ran without issue.

can't npm install bcrypt in my docker image

I'm trying to get my Sails.js app up and running using the standard node Docker image but the build is failing when it tries to npm install bcrypt.
> bcrypt#0.8.0 install /myapp/node_modules/bcrypt
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: node-v0.10.33.tar.gz local checksum 822ba41f2d77b704ab63e244dfef7431b31893c19bfe3bf228c06b6aff063ed5 not match remote 75dc26c33144e6d0dc91cb0d68aaf0570ed0a7e4b0c35f3a7a726b500edd081e
gyp ERR! stack at deref (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:299:20)
gyp ERR! stack at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:340:13)
gyp ERR! stack at IncomingMessage.emit (events.js:117:20)
gyp ERR! stack at _stream_readable.js:943:16
gyp ERR! stack at process._tickCallback (node.js:419:13)
gyp ERR! System Linux 3.16.1-tinycore64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /pos/node_modules/bcrypt
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
Alternatively sometimes it simply fails as follows:
> bcrypt#0.8.0 install /myapp/node_modules/bcrypt
> node-gyp rebuild
Killed
And sometimes it just hangs indefinitely at
> bcrypt#0.8.0 install /pos/node_modules/bcrypt
> node-gyp rebuild
My Dockerfile looks like:
FROM node:0.10.33
# copy the source files into the image
ADD . /myapp
# Define working directory.
WORKDIR /myapp
# Install node-gyp as global and ensure it's all clean and tide
RUN npm install -g node-gyp && \
node-gyp clean && \
npm cache clean
# Install project dependencies
RUN npm install
# Expose sails port (still in development mind you)
EXPOSE 1337
# Define default command.
CMD ["node app"]
Things I've tried
this post in another Stackoverflow thread suggested I should also RUN apt-get -y install g++ but adding that to my Dockerfile made no difference and it just reports that g++ is already the newest version.
this post suggested I ensure openssl is installed so I added RUN apt-get install -y openssl that that also reported openssl is already the newest version.
I've also tried RUN apt-get install -y build-essential but that too reports that it's already the latest version.
I've seen suggestions that Node needs to be installed as a legacy version, which is something the standard Node image ought to be responsible for, if necessary I believe, so I've also reported this as an issue with the docker-library/node project.
In the meantime, what else ought I try?
Thanks to everyone whose advice in the comments and answers steered me to my conclusion.
The issue was either some sort of corruption within my docker install, or some sort of incompatibility between dvm and fig, but I solved this problem as follows
dvm down
brew remove fig
brew remove dvm
brew remove docker
brew cleanup --force -s
rm -rf ~/VirtualBox VMs/boot2docker-vm
brew install docker
brew install boot2docker
boot2docker init
boot2docker up
echo export DOCKER_TLS_VERIFY=1 > ~/.bash_profile
echo export DOCKER_CERT_PATH=~/.boot2docker/certs/boot2docker-vm > ~/.bash_profile
echo export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 > ~/.bash_profile
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
brew install fig
fig build web
and voila - it worked.
The trick really seemed to be that I had a couple of conflicting bits of crud in my original boot2docker-vm from having it installed originally via the installer and then later by homebrew and boot2docker colliding somehow with dvm. By wiping it all back to bare metal and rebuilding from scratch it all worked nicely.

Node.js: How to install NPM

I have cygwin and node.exe (0.5.7) installed on my window XP.
When I git clone npm(1.0.30), cd npm, then "make install", there are lots of node_modules cloning.
But it stopped when execute "node cli.js install git+https://github.com/isaac/ronnjs.git".
The following is my npm-debug.log.
info it worked if it ends with ok
verbose cli [ 'E:\node\node.exe', verbose cli
'e:\github\npm\cli.js', verbose cli 'cache', verbose cli
'clean' ] info using npm#1.0.30 info using node#v0.5.7
verbose config file C:\Documents and Settings\zhangchiqing.npmrc
verbose config file E:\etc\npmrc ERR! prefix directory not
found ERR! Error: ENOENT, �����ɹ����ɡ� ERR! 'E:' ERR!
Report this entire log at: ERR!
http://github.com/isaacs/npm/issues ERR! or email it to: ERR!
npm-#googlegroups.com ERR! ERR! System Windows_NT
5.1.2600 ERR! command "E:\node\node.exe" "e:\github\npm\cli.js" "cache" "clean" ERR! cwd E:\github\npm ERR! node -v v0.5.7
ERR! npm -v 1.0.30 verbose exit [ 1, true ]
This works in Ubuntu. You have to use older version of node.
sudo apt-get install -y g++ libssl-dev apache2-utils curl git-core
git clone git://github.com/joyent/node.git
cd node
git checkout v0.4.11
./configure
make
sudo make install
node -v
curl https://npmjs.org/install.sh | sudo sh
npm -v

Resources