Closed jackHedaya closed 2 years ago
Hi @jackHedaya 👋
Thanks for the feedback. 👍
Can you share information about your docker-compose
setup?
What's the Docker command line or options used?
Are you using the puppeteer example available here ?
Thanks!
Thank you for reaching out and sure!
Dockerfile
FROM zenika/alpine-chrome:with-node
# Prevent yarn from reinstalling Chrome
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 1
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
# Set Node to production
ENV NODE_ENV production
# Set app working directory
WORKDIR /usr/src/app
# Copy dependency list and install
COPY --chown=chrome package.json yarn.lock ./
RUN yarn install --unsafe-perm=true --production --frozen-lockfile
# Install pm2 globally as root then switch back
USER root
RUN npm install -g pm2
USER chrome
# Copy files to working directory
COPY --chown=chrome ./dist .
# Set up process manager and run Express
ENTRYPOINT [ "tini", "--" ]
CMD [ "pm2-runtime", "npm", "--", "start" ]
docker-compose.yml
version: '3'
services:
app:
build: .
env_file:
- .env
ports:
- '3001:3001'
Puppeteer Initializer
protected async createBrowser(
args?: import('puppeteer').LaunchOptions
): Promise<import('puppeteer').Browser> {
return puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
...args,
})
}
Hi @jackHedaya
Thanks for the example! 👍
Did you succeed on a classic machine? not an Apple Silicon
?
I've never encountered this problem before while using an Intel Mac
I have the same issue on apple silicon. Any news on this?
Hi @jackHedaya @Joebayld 👋
Sorry but I didn't have a Apple Silicon. 😊
Have you seen this issue from the Puppeteer side? puppeteer issue: puppeteer/puppeteer#6622
Please notice that I don't know how Docker is working on Apple Silicon. It's a ARM based computer.
Perhaps you could make some tests to discover where is the problem...
docker container run docker/whalesay cowsay Hello
?I only have Apple Silicon so that's all I can test at the moment! Lol
The issue doesn't exist when running outside the docker image (npm start), and it doesn't exist when deploying to a Google Cloud Run server. So it seems to only be Docker on macOS AS.
I can run that example container just fine. And I can also run the alpine-chrome container as well - I just get an error when making calls to puppeteer in the container.
I'll poke the puppeteer folks as it might be an issue with the library - I'm not sure!
Hi @Joebayld 👋
Thanks for the update! 🙌 Please keep me updated!
Hi @Joebayld @jackHedaya 👋
Does it work now on Apple Silicon? 😊
Any news @Joebayld @jackHedaya ? 😊 Thanks!
Hi! As of now it is not working, I believe it may be a puppeteer problem though. It seems to be attached to this issue
Hi @jackHedaya
Thanks for the update! 👍
https://github.com/puppeteer/puppeteer/issues/1947#issuecomment-815808274 helped me solve this issue
Hi @jlandure, are there any plans to publish a multi-arch image on Docker Hub for with-puppeteer
?
I was running into crashes using my new MacBook M1 Air whereas my previous Intel MacBook had no issues. Ended up building my own version of this with an arm64v8 alpine image and my crash issue was resolved. You can find the image at avidtraveler/alpine-chrome.
That's great, @ssoper! Could you please publish your customized Dockerfile and its context files if possible?
Hi @ssoper 👋
Thanks for the update! And congrats to make it working with M1.
Do you think you can contribute to this image by adding your arm64v8 version? 👍 It could be interesting for @drpayyne and the rest of the community 😊
Hi @jlandure, what's the image build process that you use? I'd love to contribute to making this repo multi-arch as well :)
Hi @drpayyne
Thanks for your motivation 💪
Very simple: the build process is done using Docker Hub AutoBuild.
💬 If you're interested, please create a PR and we will discuss about making the repo multi-arch!
@drpayyne @jlandure the only difference is the very first line FROM arm64v8/alpine:latest
, everything else in the Dockerfile is identical.
Here is my fork, lmk what next steps are, happy to help out.
I am running the ARM native version of Docker Desktop v20.10.8 on Big Sur.
Is there a reason we need to use that specific image? alpine:latest
already provides multi-arch images at https://hub.docker.com/_/alpine?tab=tags&page=1&ordering=last_updated&name=latest.
I've been working on rebuilding existing images for both architectures so all that we need to do is rebuild our images for both platforms. We have to maybe customize the images a little, but I'll need to look into the specifics for this repository. Let me get back on this with a PR.
@drpayyne when I specified the platform in the docker command to retrieve and run the image, it claimed there was no such platform.
docker: Error response from daemon: image with reference zenika/alpine-chrome was found but does not match the specified platform: wanted linux/arm64/v8, actual: linux/amd64.
Yes, you're right. This repository's images (zenika/*
) do not provide ARM builds. But the source image you had mentioned that you modified isn't required is what I mean.
the only difference is the very first line FROM arm64v8/alpine:latest, everything else in the Dockerfile is identical.
So we can continue using alpine:latest
as the source image and we have to build the same Dockerfile for multiple platforms. I use this command to build the Dockerfile for multiple platforms - docker buildx build --platforms=linux/arm64,linux/amd64 .
.
So effectively we just need to rebuild the same Dockerfile for ARM.
Note: Some Dockerfiles here like puppeteer need some customization which I'll be looking into once I fix my PHP rebuild :)
@ssoper - I've just rebuilt the base image of this repository for both architecture at https://github.com/drpayyne/chrome/pkgs/container/chrome. All users can pull this tag and it'll download the appropriate architecture.
@drpayyne did it resolve your crash issue?
I'm not sure as to what exactly is causing the crash reported here, but you could test it out by running docker run -it --rm ghcr.io/drpayyne/chrome bash
. Any feedback is appreciated! I'm currently building the rest of the images like Node and Puppeteer, so I'll test them all together.
the crashes I was seeing locally were related to being unable to parse /proc/self/maps
along with a host of GPU errors.
Any specific commands that I need to test? @ssoper
I'm publishing the multi-arch packages at https://github.com/drpayyne?tab=packages&repo_name=chrome. Please test anything you can
@drpayyne ran your image against my complex series of browser interactions (primarily with the E*TRADE website) and it worked perfect 💯
That's awesome! Let me check if all the Dockerfiles in this repo build, and then I'll create a PR
cc/ @jlandure
@ssoper, I'm getting the below error if I run the base chrome image. Any idea what's causing this in my machine since it seems to work for you? I'm seeing a few answers online, but not sure which is the best approach to fix this.
docker run -it --rm ghcr.io/drpayyne/chrome bash
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[0907/154002.918286:FATAL:zygote_host_impl_linux.cc(191)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid).
Received signal 6
[end of stack trace]
might come down to what arguments you are launching with, here is my run command. could also depend on what version of Docker you’re running (I noted in a prev comment what I’m running)
docker container run -d -p 9222:9222 ghcr.io/drpayyne/chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" about:blank
Ah! Thank you. Just found https://github.com/Zenika/alpine-chrome/issues/33 too. My bad, apologies. My multi-arch image builds work good in that case.
great to hear @drpayyne! @jlandure what work remains so that we can pull zenika/alpine-chrome
with a --platform linux/arm64/v8
switch to get the image we need?
Discussion PR opened at https://github.com/Zenika/alpine-chrome/pull/182.
Describe the bug On Apple Silicon, Chromium will crash on launch with the following message:
To Reproduce
$ docker-compose up --build -d
What is the expected behavior? Chrome not to crash
What is the actual behavior? Chrome crashes
Possible solution Not sure –– hoping someone here might know what's going on
Logs If applicable, add logs to help explain your problem.
Versions
Additional context This happens very rarely when running the program locally. When running through the image, this happens every time.