Sign inSign up

kitce/xvfb-node

By kitce

•Updated over 8 years ago

Running display-based Node.js application on headless environment should be easier than ever

Image
0

918

kitce/xvfb-node repository overview

⁠docker-xvfb-node

Normally, Nightmare (or other similar libraries) will not operate properly on headless Linux environment.

Thanks XVFB for providing a "fake" display to the system.

⁠Usage

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.

⁠Options

⁠XVFB_SCREEN (default : 800x600x8)

Configure the fake display (Reference)⁠

Append this as the environment variable on docker run

⁠Example
docker run -it -e "XVFB_SCREEN=1024x768x16" my-app:latest
⁠Output
Screen : 1024x768x16
Xvfb is running - pid : 7
> // JavaScript here

⁠Example

⁠Dockerfile
FROM kitce/xvfb-node:latest

WORKDIR /app
COPY . ./
RUN yarn install --pure-lockfile

CMD ["yarn", "start"]
⁠Build
docker build -t example:latest .

duckduckgo example⁠

Tag summary

Content type

Image

Digest

Size

453.1 MB

Last updated

over 8 years ago

docker pull kitce/xvfb-node