diff --git a/README.md b/README.md index 4ce842e60..fe1f54db9 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,10 @@ Read more about Omnivore on our blog. > /etc/apt/sources.list.d/google.list' \ +# && apt-get update \ +# && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \ +# --no-install-recommends \ +# && rm -rf /var/lib/apt/lists/* + +# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true +# ENV CHROMIUM_PATH "/usr/bin/google-chrome-stable" + +# ------------------------ + +# FROM --platform=linux/arm64 node:14.18 + +# RUN apt-get update \ +# && apt-get install -y chromium \ +# && apt-get install -y ca-certificates \ +# fonts-liberation \ +# libappindicator3-1 \ +# libasound2 \ +# libatk-bridge2.0-0 \ +# libatk1.0-0 \ +# libc6 \ +# libcairo2 \ +# libcups2 \ +# libdbus-1-3 \ +# libexpat1 \ +# libfontconfig1 \ +# libgbm1 \ +# libgcc1 \ +# libglib2.0-0 \ +# libgtk-3-0 \ +# libnspr4 \ +# libnss3 \ +# libpango-1.0-0 \ +# libpangocairo-1.0-0 \ +# libstdc++6 \ +# libx11-6 \ +# libx11-xcb1 \ +# libxcb1 \ +# libxcomposite1 \ +# libxcursor1 \ +# libxdamage1 \ +# libxext6 \ +# libxfixes3 \ +# libxi6 \ +# libxrandr2 \ +# libxrender1 \ +# libxss1 \ +# libxtst6 \ +# lsb-release \ +# wget \ +# xdg-utils + +FROM node:14.18-alpine + +# Installs latest Chromium (92) package. +RUN apk add --no-cache \ + chromium \ + nss \ + freetype \ + harfbuzz \ + ca-certificates \ + ttf-freefont \ + nodejs \ + yarn + +# Tell Puppeteer to skip installing Chrome. We'll be using the installed package. +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ + PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser + +# Puppeteer v10.0.0 works with Chromium 92. +RUN yarn add puppeteer@10.0.0 + +# Add user so we don't need --no-sandbox. +RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \ + && mkdir -p /home/pptruser/Downloads /app \ + && chown -R pptruser:pptruser /home/pptruser \ + && chown -R pptruser:pptruser /app + +# Run everything after as non-privileged user. +WORKDIR /app + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true +ENV CHROMIUM_PATH /usr/bin/chromium-browser +ENV LAUNCH_HEADLESS=true + +COPY package.json . +COPY yarn.lock . +COPY tsconfig.json . +COPY .prettierrc . +COPY .eslintrc . + +COPY /packages/puppeteer-parse/package.json ./packages/puppeteer-parse/package.json + +RUN yarn install --pure-lockfile + +ADD /packages/puppeteer-parse ./packages/puppeteer-parse + +EXPOSE 8080 + +# USER pptruser +ENTRYPOINT ["yarn", "workspace", "@omnivore/puppeteer-parse", "start"] \ No newline at end of file diff --git a/packages/puppeteer-parse/index.js b/packages/puppeteer-parse/index.js index b2a47ccbd..3f845b412 100644 --- a/packages/puppeteer-parse/index.js +++ b/packages/puppeteer-parse/index.js @@ -122,7 +122,7 @@ const getBrowserPromise = (async () => { args: chromium.args, defaultViewport: { height: 1080, width: 1920 }, executablePath: process.env.CHROMIUM_PATH || (await chromium.executablePath), - headless: process.env.IS_LOCAL ? false : chromium.headless, + headless: process.env.LAUNCH_HEADLESS ? true : chromium.headless, timeout: 0, }); })();