Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nightmare.js with Docker

I'm attempting to run Nightmare.js on the server. I'm well aware that it's headless on Linux, and requires xvfb. What I don't understand is why I continue to get the following error when 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's my Dockerfile:

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.

like image 406
Nick Parsons Avatar asked Oct 18 '22 07:10

Nick Parsons


1 Answers

What you can do is to put all your files in a subdirectory, say app/ and in your Dockerfile do:

ADD app/ /usr/src/app/

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

That way if you need to add more files, you wont have to add them manually in your dockerfile.

PS: It works with COPY too

like image 131
michael_bitard Avatar answered Nov 03 '22 00:11

michael_bitard