Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BrianVia/5826f1057e2d6c07836a2c3fc5ce4104 to your computer and use it in GitHub Desktop.
Save BrianVia/5826f1057e2d6c07836a2c3fc5ce4104 to your computer and use it in GitHub Desktop.
# Set the base image to Node 18
FROM node:18
# File Author / Maintainer
LABEL maintainer=your_email@gmail.com"
# Update the repository sources list
RUN apt-get update && apt-get upgrade -y
# Install Chromium
RUN apt-get install -y chromium
# Set the working directory to /app
WORKDIR /app
# Bundle your app source inside the docker image
COPY . .
# Install all the dependencies
RUN npm ci
# Build the API
RUN npm run build <your-app-name> # command to build an app in an NX monorepo; replace with your app build command
# Your app binds to port 8080 so you'll use the EXPOSE instruction to have it mapped by the docker daemon
EXPOSE 8080
# Set environment variable to disable Chromium's sandbox (this is required if you are running as root)
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_ARGS='--no-sandbox'
# Start command
CMD [ "node", "dist/apps<your-app-name>/main.js" ] # again replace this with your specific node command to start your app/service
@gregg-cbs
Copy link

gregg-cbs commented Apr 9, 2024

Thanks for this. It would be great if you also provided the puppeteer code. We are getting an error when trying to run this container on App Platform:
[html-to-pdf] [2024-04-09 11:18:04] Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment