Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 16, 2024 09:29 am GMT

Docker Puppeeteer Node Railway

Want to use puppeteer in node node and then deploy it on railway.app 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 imageFROM node:21.7.3-slimRUN apt-get update && apt-get install gnupg wget -y && \  wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \  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/*# Set the working directory to /appWORKDIR /app# Copy the package.json and pnpm-lock.yaml filesCOPY package.json pnpm-lock.yaml ./# Install dependencies using pnpmRUN npm install -g pnpm && pnpm install# Copy the rest of the application codeCOPY . .# Set the DATABASE_URL environment variableENV DATABASE_URL="postgres://postgres.<passwoedtodb>.supabase.com:5432/postgres"# Set the NEXT_PUBLIC_API_URL environment variableENV NEXT_PUBLIC_API_URL="https://example.com"# Build the TypeScript code and run Prisma migrationsRUN pnpm run build# Expose the port that your Express.js app is running onEXPOSE 3000# Start the applicationCMD ["pnpm", "start"]

--------------------------------------------------------------------------------------------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();


Original Link: https://dev.to/om0509/docker-puppeeteer-node-railway-2lla

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To