https://github.com/shivjm/docker-node-chromium
A Docker image with preinstalled Chromium and Node.JS on Alpine Linux.
https://github.com/shivjm/docker-node-chromium
alpine-linux chromium docker nodejs puppeteer
Last synced: 6 months ago
JSON representation
A Docker image with preinstalled Chromium and Node.JS on Alpine Linux.
- Host: GitHub
- URL: https://github.com/shivjm/docker-node-chromium
- Owner: shivjm
- License: mit
- Created: 2019-11-14T22:05:28.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T15:04:39.000Z (almost 2 years ago)
- Last Synced: 2024-08-20T17:16:43.084Z (almost 2 years ago)
- Topics: alpine-linux, chromium, docker, nodejs, puppeteer
- Homepage:
- Size: 31.3 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-node-chromium
[](https://github.com/shivjm/docker-node-chromium/actions/workflows/publish.yml) 
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](https://github.com/GoogleChrome/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)](https://hub.docker.com/r/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](https://hub.docker.com/_/node?tab=tags&page=1&ordering=last_updated).
## Example Dockerfiles
Simple:
```Dockerfile
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:
```Dockerfile
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:
```Dockerfile
# (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)
```