DEV Community

Om Bharti
Om Bharti

Posted on

Docker Puppeeteer Node Railway

Want to use puppeteer in node node and then deploy it on or any related hosting platform, here is my working docker file and puppeteer config. You can use it

-------------------------------------------------------------------------------------------DOCKER CONFIG FILE--------------------------------------------------------------------------------------------------------------------------------------------------------------

# Use the latest Node.js LTS (Long Term Support) version as the base image
FROM node:21.7.3-slim

RUN apt-get update && apt-get install gnupg wget -y && \
  wget --quiet --output-document=- | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
  sh -c 'echo "deb [arch=amd64] 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/*

# Set the working directory to /app

# Copy the package.json and pnpm-lock.yaml files
COPY package.json pnpm-lock.yaml ./

# Install dependencies using pnpm
RUN npm install -g pnpm && pnpm install

# Copy the rest of the application code
COPY . .

# Set the DATABASE_URL environment variable
ENV DATABASE_URL="postgres://postgres.<passwoedtodb>"

# Set the NEXT_PUBLIC_API_URL environment variable

# Build the TypeScript code and run Prisma migrations
RUN pnpm run build

# Expose the port that your Express.js app is running on

# Start the application
CMD ["pnpm", "start"]
Enter fullscreen mode Exit fullscreen mode

--------------------------------------------------------------------------------------------import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
// headless: false,
executablePath: '/usr/bin/google-chrome',
args: ["--no-sandbox", "--disable-setuid-sandbox"],
const page = await browser.newPage();

Top comments (0)