Skip to content

Instantly share code, notes, and snippets.

@omirobarcelo
Created September 20, 2024 06:23
Show Gist options
  • Save omirobarcelo/e2f94ac55a2157b6cfeefdf79d6df4ef to your computer and use it in GitHub Desktop.
Save omirobarcelo/e2f94ac55a2157b6cfeefdf79d6df4ef to your computer and use it in GitHub Desktop.
Minimal Puppeteer Dockerfile
# Base image
FROM debian:bullseye-slim
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Setup the base OS
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends build-essential \
apt-transport-https curl git ca-certificates gnupg2 apt-utils nodejs dnsutils \
libasound2 libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libdrm2 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 libudev1 libuuid1 libx11-6 libx11-xcb1 libxcb-dri3-0 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxss1 libxtst6 \
fonts-liberation libnss3 lsb-release xdg-utils wget
RUN apt-get install curl gnupg -y \
&& curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install google-chrome-stable -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV NVM_DIR /usr/local/nvm
RUN mkdir -p /usr/local/nvm
ENV NODE_VERSION 20.13.0
# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.39.0/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# Test
RUN npm --version
RUN node --version
# Set timezone
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
# Copy package.json and package-lock.json
COPY package.json ./
# Install dependencies
RUN npm install
# Copy application code
COPY goldcar ./goldcar
COPY utils ./utils
COPY .env ./
# Command to run minimal script
CMD ["npm", "run", "minimal"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment