Created
June 9, 2023 01:37
-
-
Save BrianVia/5826f1057e2d6c07836a2c3fc5ce4104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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