Running display-based Node.js application on headless environment should be easier than ever
918
Normally, Nightmare (or other similar libraries) will not operate properly on headless Linux environment.
Thanks XVFB for providing a "fake" display to the system.
docker pull kitce/xvfb-node:latest
Use it like how you use the official Node.js Docker image.
By the time of writing this image, the latest LTS version of Node.js is 8.11.2, so the base image is node:8.
By default, this image "creates" a screen with resolution 800x600 and depth 8 (800x600x8), this can be configured by the environment variable XVFB_SCREEN, see Options below.
Screen number (screennum) and server number are 0 and :99 respectively.
This image exports DISPLAY=":99.0" to env, Nightmare will then look for the display on :99.0 automatically.
Screen number and server number will be configurable in the future.
XVFB_SCREEN (default : 800x600x8)Configure the fake display (Reference)
Append this as the environment variable on docker run
docker run -it -e "XVFB_SCREEN=1024x768x16" my-app:latest
Screen : 1024x768x16
Xvfb is running - pid : 7
> // JavaScript here
FROM kitce/xvfb-node:latest
WORKDIR /app
COPY . ./
RUN yarn install --pure-lockfile
CMD ["yarn", "start"]
docker build -t example:latest .
Content type
Image
Digest
Size
453.1 MB
Last updated
over 8 years ago
docker pull kitce/xvfb-node