Am I correct in assuming this package can't be used when using a containerized setup? #700
Replies: 2 comments
-
I have the same issue... |
Beta Was this translation helpful? Give feedback.
-
I do have this containerised. It's been running in my production environment for about 5 years. Unfortunately since it's been years since I set it up some things are hazy, but I'm happy to attempt to help if you have specific questions about my setup. I came looking at these issues again because I had to upgrade my project to use current versions of browsershot, and by implication Puppeteer. Essentially, I have a local Docker image for a PHP container which does contain node and npm, and anything else (eg I also have a separate container for deploying code (which is where I run I also had to tell Puppeteer to install chrome into the project root, rather than its default The custom broswershot PHP image's dockerfile: # "docker_" here comes from the containing directory.
FROM docker_php-fpm-current:latest
RUN apt-get update && apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgbm1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
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 \
ca-certificates \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
wget
# Install nodejs & npm. Debian's default `apt-get` installed an old version (v10.24.0).
# See https://github.com/nodesource/distributions
RUN curl -fsSL https://deb.nodesource.com/setup_current.x | bash - \
&& apt-get install -y nodejs The above image extends my main php image: # https://hub.docker.com/_/php
# "buster" is Debian 10.
FROM php:8.1-fpm-buster
RUN apt-get update && apt-get install -y \
apt-utils \
libfreetype6-dev \
libjpeg62-turbo-dev \
libldap2-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
openssl \
zlib1g-dev \
libicu-dev \
g++ \
# See https://gist.github.com/giansalex/2776a4206666d940d014792ab4700d80 :
# Others are included in base image; run `php -m` to list them all.
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-configure intl \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install bcmath exif intl ldap opcache pcntl pdo_mysql zip
RUN ln -s /usr/local/etc/php/php.ini-production /usr/local/etc/php/conf.d/php.ini The Puppeteer cache config is in a file called const {join} = require('path');
/**
* @type {import("puppeteer").Configuration}
*
* See https://pptr.dev/guides/configuration#changing-the-default-cache-directory
*
* Without this, the chromium binary is supposedly downloaded to the user root
* but I never found it.
*/
module.exports = {
// Changes the cache location for Puppeteer to the project root.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
}; Obviously all the above contains a lot of stuff specific to my project, but hopefully something there may help someone else. |
Beta Was this translation helpful? Give feedback.
-
I have PHP, Nginx, MySQL, Redis and NodeJS containers in my project.
This package always assumes the PHP container has CLI access to node and npm, correct? I can't find any good resources on how I would implement this package in such an environment. The documentation, surprisingly, does not mention anything docker related.
Beta Was this translation helpful? Give feedback.
All reactions