Skip to content

A Docker image with preinstalled Chromium and Node.JS on Alpine Linux.

License

Notifications You must be signed in to change notification settings

shivjm/docker-node-chromium

Repository files navigation

docker-node-chromium

Build and publish to Docker Hub https://hub.docker.com/r/shivjm/node-chromium

A Docker image with preinstalled Chromium and Node.JS on Alpine Linux or Debian. Good minimal base image for users of scraping libraries like Puppeteer.

Repository

https://github.com/shivjm/docker-node-chromium/

Issues

https://github.com/shivjm/docker-node-chromium/issues/

Tags

See all available tags at Docker Hub (shivjm/node-chromium). No latest image is provided.

Alpine Linux

nodeN-chromiumC-alpine, where N is the Node.js major version number (12, 14, 16, 17, 18, 19, 20, or 22) and C is the Chromium major version number. For example, to use Node.js 14 with Chromium 81, use the shivjm/node-chromium:node14-chromium81-alpine image.

Debian

nodeN-chromiumC-debian, where N is the Node.js major version number (12, 14, 16, 17, 18, 19, 20, or 22) and C is the Chromium major version number. For example, to use Node.js 14 with Chromium 81, use the shivjm/node-chromium:node14-chromium81-debian image.

Versioning

The newest version of Chromium provided by Alpine Linux or Debian is used.

The version of the base distribution depends on the upstream Node images.

Example Dockerfiles

Simple:

FROM shivjm/node-chromium:node14-chromium99-alpine

WORKDIR /usr/src/app

COPY package.json package-lock.json ./

RUN npm ci

COPY src .

ENTRYPOINT ["npm", "start"]

Multi-stage build to separate development dependencies from production:

FROM node:12-alpine AS build

WORKDIR /usr/src/app-deps

COPY package.json package-lock.json ./

RUN npm ci

COPY . .

RUN npm run compile-my-code && \
  npm prune --production

FROM shivjm/node-chromium:node18-chromium108-debian

USER node

WORKDIR /usr/src/app

COPY package.json package-lock.json ./

COPY --from=build /usr/src/app-deps/node_modules ./node_modules

COPY --from=build /usr/src/app-deps/dist ./dist

ENV NODE_ENV=production

ENTRYPOINT ["npm", "start", "--quiet"]

Puppeteer

When you install Puppeteer, it also downloads a known version of Chromium to store under node_modules, and defaults to using that binary. You can skip this download using the environment variable PUPPETEER_SKIP_CHROMIUM_DOWNLOAD. You’ll also need to set PUPPETEER_EXECUTABLE_PATH to the installed Chromium. A partial example:

# (setup elided)

# install dependencies but not Chromium:

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1

RUN npm install

# make Puppeteer use correct binary:

ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# (other build details elided)

About

A Docker image with preinstalled Chromium and Node.JS on Alpine Linux.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published