Puppeteer on DigitalOcean's App Platform
10.05.2024
One of the NodeJS apps that I am developing is generating PDF documents with puppeteer. Having everything hosted and working on DIgitalOcean's App Platform was a small challenge!
This is going to be a quicky. Not so much an article even as just a brief summary of the set up I needed to do in order to have puppeteer
working on DigitalOcean's App Platform.
So, in order to have it all fully working in my production build on App Platform, I needed to switch over to Docker and this is the Dockerfile
:
FROM node:18-slim
WORKDIR /usr/src/app
COPY package*.json ./
COPY yarn.lock ./
COPY patches ./patches
RUN yarn install && yarn cache clean
RUN apt-get update && apt-get install -y \
fonts-noto-color-emoji \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libdrm2 \
libglib2.0-0 \
libgtk-3-0 \
libgbm1 \
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 \
xz-utils \
--no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN yarn build:server
CMD [ "yarn", "start" ]
EXPOSE 8080
App Platform should automatically detect whether you are using Docker for production builds or not. If you decide to manually change the config though, just use the app spec file (App Platform Dockerfile Build Reference :: DigitalOcean Documentation)
By the way - make sure your server has enough resources to run puppeteer
smoothly as the lowest droplet tier they offer might not be enough...
That's it! Hope this helps someone out there!
Daniel