Nightmare.js with docker

I am trying to run Nightmare.js on a server. I well know that it is headless on Linux, and requires xvfb . I do not understand why I keep getting the following error in DEBUG mode:

  nightmare queuing process start +0ms nightmare queueing action "useragent" +3ms nightmare queueing action "goto" for https://news.ycombinator.com +2ms nightmare queueing action "cookies" +1ms nightmare queueing action "goto" for https://news.ycombinator.com/login +0ms nightmare queueing action "type" +1ms nightmare queueing action "type" +0ms nightmare queueing action "click" +0ms nightmare queueing action "wait" +1ms nightmare queueing action "goto" for https://news.ycombinator.com/item?id=11878025 +0ms nightmare queueing action "click" +0ms nightmare queueing action "wait" +1ms nightmare running +0ms nightmare electron child process exited with code 2: undefined +25ms 

Here is my Docker file:

 FROM node:latest RUN apt-get update &&\ apt-get install -y \ xvfb \ x11-xkb-utils \ xfonts-100dpi \ xfonts-75dpi \ xfonts-scalable \ xfonts-cyrillic \ x11-apps \ clang \ libdbus-1-dev \ libgtk2.0-dev \ libnotify-dev \ libgnome-keyring-dev \ libgconf2-dev \ libasound2-dev \ libcap-dev \ libcups2-dev \ libxtst-dev \ libxss1 \ libnss3-dev \ gcc-multilib \ g++-multilib RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app RUN npm install CMD DEBUG=nightmare* xvfb-run --server-args="-screen 0 1024x768x24" node tux.js -s hn -m create -p 11878025 

Any thoughts? Help would be greatly appreciated.

+5
source share
3 answers

What you can do is put all your files in a subdirectory, say application / and in your Docker file:

 ADD app/ /usr/src/app/ 

of course, in your application folder there will be env.sh, package.json, tux.js and the lib directory

Thus, if you need to add more files, you do not have to add them manually to the docker file.

PS: It also works with COPY

+2
source

Ok, so I realized what the problem is. Apparently, he did not like the copy syntax in my Docker file. I ended up using ADD and it worked.

 ADD /lib /usr/src/app/lib ADD env.sh /usr/src/app ADD package.json /usr/src/app ADD tux.js /usr/src/app 
+1
source

An error that is read undefined is a sign that you are missing a package. In the end, if the package is not installed, then how to determine it? This would mean that you did not build the container correctly, and I think I see the culprit.

 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app *COPY . /usr/src/app* RUN npm install 

According to the dockerfile documentation , the COPY command copies the files , not the directories that you specified with COPY . /usr/src/app COPY . /usr/src/app ; Try replacing instead . to * , as this will indicate ALL files in the current directory that you decide to initiate docker build .

0
source

All Articles