-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't run it inside docker container #90
Comments
I had success running it in a Docker container. I started from zenika/alpine-chrome:with-node and made sure to set the arguments:
|
@frinyvonnick just for context:
|
Hey @frinyvonnick, @yang093, and @ilyapavkin! I was having the same issue a week back, but I was able to run it after using @joshk0 's tip and looking around for a bit. Using this code, I was able to create this Dockerfile: FROM zenika/alpine-chrome:with-node
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 1
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
WORKDIR /usr/src/app
COPY --chown=chrome package*.json ./
RUN npm install
COPY --chown=chrome . ./
ENTRYPOINT ["tini", "--"]
CMD ["npm", "start"] Also, these were the puppeteer args I added to the function, since the function wasn't running in the container before I did this: puppeteerArgs: {
headless: true,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--headless",
"--disable-gpu",
"--disable-dev-shm-usage",
],
}, I hope this helps! |
It could be interesting to add explanations on this topic in the README? |
@sBx99 suggestion worked for me. Fonts were not working after using alpine-chrome, so I needed to do a little hacking to manually add (because I am using special fonts for this project) all the fonts into /usr/share/fonts folder on docker container. Please be aware that you need to have root privileges in order to create a folder inside /usr/share/fonts and copy your fonts inside. If you are using Google Fonts, you can just add it to your dockerfile. |
This is my docker file:
I'm getting is error: I tried different solutions but it's not working, Can someone tell how can I fix this? I tried the solution above but I think I'm missing something |
when i set the puppeteerArgs in nodeHtmlToImage func, i fix this. |
@Nixum Thanks |
Gotten things working on a Rpi 4 arm64 running docker `FROM node:17.4.0 WORKDIR /app puppeteerArgs: { |
I'm struggling to get this to work on latest version (including building latest commit) even with some of the tips in this thread. Trying older versions of puppateer. The latest version on alpine I think is not possible to get working. I'm trying older versions that have older versions of puppateer now. |
@roninjin10 I'm using
|
@ZainUrRehmanKhan Dockerfile
And here is my code return nodeHtmlToImage({
type: 'png',
// .nft-image-render
selector: `.${nftImageClass}`,
puppeteerArgs: {
headless: true,
executablePath: '/usr/bin/chromium-browser',
args: [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-sandbox',
'--headless',
],
},
html: `
<!DOCTYPE html>
<html lang="en">
<head>
<style>
${nftImageCss}
</style>
</head>
<body>
${ReactDOMServer.renderToString(
<NFTImageRender
isPNG={false}
imageUri={imageUri}
{...optimistNftProps}
/>,
)}
</body>
</html>`,
}) And this is puppeteer debug data
|
My latest run got a different error I changed the options to this:
And got this error which is different
|
In version 4.0.0 I updated puppeeteer to version 21.0.1. It might help you in some way? |
Oh I did get this working. Forgot to update. Here. If anybody has issues ping me and I can send you the combination of dockerfile plus runtime config that got it working. |
One issue I had btw was that I had a working docker config multiple times following advice in this thread but it still failed on macOS on mac silicone specifically without me realizing it was macOS based issues |
Why can't you post it here @roninjin10? |
No description provided.
The text was updated successfully, but these errors were encountered: