mirror of
https://github.com/hanzoai/puppeteer.git
synced 2026-09-24 17:02:14 +00:00
02236ee621
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
49 lines
2.0 KiB
Docker
49 lines
2.0 KiB
Docker
FROM node:24-bookworm@sha256:5711a0d445a1af54af9589066c646df387d1831a608226f4cd694fc59e745059
|
|
# Configure default locale (important for chrome-headless-shell).
|
|
ENV LANG=en_US.UTF-8
|
|
# UID of the non-root user 'pptruser'
|
|
ENV PPTRUSER_UID=10042
|
|
# Attempts to start a new DBUS session if none is present
|
|
ENV DBUS_SESSION_BUS_ADDRESS=autolaunch:
|
|
|
|
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
|
|
# Note: this installs the necessary libs to make the bundled version of Chrome that Puppeteer
|
|
# installs, work.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros \
|
|
fonts-kacst fonts-freefont-ttf dbus dbus-x11
|
|
|
|
|
|
# Add pptruser.
|
|
RUN groupadd -r pptruser && useradd -u $PPTRUSER_UID -rm -g pptruser -G audio,video pptruser
|
|
|
|
USER $PPTRUSER_UID
|
|
|
|
WORKDIR /home/pptruser
|
|
|
|
COPY puppeteer-browsers-latest.tgz puppeteer-latest.tgz puppeteer-core-latest.tgz ./
|
|
|
|
|
|
# Install @puppeteer/browsers, puppeteer and puppeteer-core into /home/pptruser/node_modules.
|
|
RUN npm i ./puppeteer-browsers-latest.tgz ./puppeteer-core-latest.tgz ./puppeteer-latest.tgz \
|
|
&& rm ./puppeteer-browsers-latest.tgz ./puppeteer-core-latest.tgz ./puppeteer-latest.tgz
|
|
|
|
# Install system dependencies as root.
|
|
USER root
|
|
# Overriding the cache directory to install the deps for the Chrome
|
|
# version installed for pptruser.
|
|
RUN PUPPETEER_CACHE_DIR=/home/pptruser/.cache/puppeteer \
|
|
npx puppeteer browsers install chrome --install-deps \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
USER $PPTRUSER_UID
|
|
# Generate THIRD_PARTY_NOTICES using chrome --credits.
|
|
ARG JS_CODE=" \
|
|
import { execSync } from 'node:child_process'; \
|
|
import puppeteer from 'puppeteer'; \
|
|
const executable = await puppeteer.executablePath(); \
|
|
execSync(executable + ' --credits', {stdio: 'inherit'}); \
|
|
"
|
|
RUN node --input-type=module -e "$JS_CODE" > THIRD_PARTY_NOTICES
|