rod
rod copied to clipboard
Create docker image builds for linux/arm and linux/arm64
Is your feature request related to a problem
The go-rod/rod image provided in the docker image repository is built for the x86 architecuture. With the rise of arm architecture on smaller portable devices (i.e. raspberry pi) it makes sense to also create a arm based image.
Describe the solution you'd like
Add images for arm.
Agree. Can you help us to investigate how to do it?
Sure! I actually built an rodorg/rod image locally for arm64 currently running on my raspberry pi by using buildx. How are images now distrubted to dockerhub? If you give me access I could see if I can modify the pipeline (here some info on how it can be done: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ )
Great! Everything in Rod is public, it's the same with the docker image. Once your dockerfile is merged, it will automatically be available in dockerhub. The current image is built by this: https://github.com/go-rod/rod/tree/master/lib/docker
The github CI will check the dockerfile with all the unit tests. Feel free to play with it:
https://github.com/go-rod/rod/blob/ad95d98dc1d87f955e1a0e10121b294a2349dfd4/.github/workflows/test.yml#L59-L70
The plan is simple, you will add new dockerfiles like arm.Dockerfile
and arm64.Dockerfile
to the folder, I will add new build rules here to auto-build it:
Click to expand
Afaik no changes are needed, so you can simply use the same dockerfile.
Then that's even better. Feel free to change any file you like.
BTW, how do we test it? I don't have an arm machine on hand.
Some useful links: https://github.com/docker/for-mac/issues/4733
I have an M1 MacBook Air if I can be of help with testing @ysmood!
On the latest master (ad95d98dc1d87f955e1a0e10121b294a2349dfd4) I built with the following:
$ uname -a
Darwin Alexandra 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
$ docker build -t rodorg/rod -f lib/docker/Dockerfile .
...
=> => exporting layers 3.4s
=> => writing image sha256:61bbd09dce07cb7c060d467cef1962a19ec1ccf09af6591410e4aec91c46e6e7 0.1s
=> => naming to docker.io/rodorg/rod
$ docker run -p 9222:9222 docker.io/rodorg/rod
Remote control url is ws://[::]:9222
2021/03/01 23:27:45 http: panic serving 172.17.0.1:55734: [launcher] Failed to get the debug url: qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
goroutine 34 [running]:
net/http.(*conn).serve.func1(0x4000188000)
/usr/local/go/src/net/http/server.go:1824 +0x110
panic(0x2c52c0, 0x4000212000)
/usr/local/go/src/runtime/panic.go:971 +0x424
github.com/go-rod/rod/lib/utils.E(...)
/rod/lib/utils/utils.go:67
github.com/go-rod/rod/lib/launcher.(*Launcher).MustLaunch(0x4000182100, 0x0, 0x0)
/rod/lib/launcher/launcher.go:319 +0xb0
github.com/go-rod/rod/lib/launcher.(*RemoteLauncher).launch(0x4000098ef0, 0x392d20, 0x40001ae000, 0x400019e000)
/rod/lib/launcher/remote_launcher.go:118 +0x148
github.com/go-rod/rod/lib/launcher.(*RemoteLauncher).ServeHTTP(0x4000098ef0, 0x392d20, 0x40001ae000, 0x400019e000)
/rod/lib/launcher/remote_launcher.go:97 +0xcc
net/http.serverHandler.ServeHTTP(0x400011a000, 0x392d20, 0x40001ae000, 0x400019e000)
/usr/local/go/src/net/http/server.go:2887 +0xbc
net/http.(*conn).serve(0x4000188000, 0x3933a0, 0x4000196000)
/usr/local/go/src/net/http/server.go:1952 +0x71c
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3013 +0x318
🤔
@lox Thanks for your info.
I think you should use the image you build. Have you tried this:
docker build -t rodorg/rod -f lib/docker/Dockerfile .
docker run --rm -p 9222:9222 rodorg/rod
I thought it was odd that the builder didn't use the tag I specified, but I must have been misreading the output of buildx
.
The command as you mentioned above works as expected!
@ysmood I'm also interested in this. I did a bunch of testing on my M1 Mac and here are my findings:
- Building the go-rod
Dockerfile
locally is necessary, but I was not able to successfully run the container using the base imageubuntu:bionic
. I had to upgrade theubuntu:focal
. When usingubuntu:bionic
I would get a GLIB version error. - The architecture support needed for Apple silicon is
linux/arm64/v8
It looks like the GH Container registry supports multi architecture builds
- Would you accept a PR that upgrades the base image of the DockerFile to
ubuntu:focal
? - Would you accept a PR to enhance your CI to include multi arch building of the docker container and pushing it to the GH Container Registry?
@ARolek Sure thing!
@ysmood Thank you for upgrading Dockerfile from ubuntu:bionic
to ubuntu:jammy
. Could you please build and push docker image to GH Container registry for latest code?
I tried to build docker image in local but it is throwing below error. I am using Docker Desktop on M1 mac.
#12 19.80 [launcher.Browser]2022/09/16 13:46:18 43%
#12 20.80 [launcher.Browser]2022/09/16 13:46:19 73%
#12 21.29 [launcher.Browser]2022/09/16 13:46:19 100%
#12 21.31 panic: exit status 127
#12 21.31
#12 21.31 goroutine 1 [running]:
#12 21.31 github.com/go-rod/rod/lib/utils.glob..func2({0x2a1080?, 0x40000a1320?})
#12 21.31 /rod/lib/utils/utils.go:60 +0x24
#12 21.31 github.com/go-rod/rod/lib/utils.E(...)
#12 21.31 /rod/lib/utils/utils.go:66
#12 21.31 main.main()
#12 21.31 /rod/lib/utils/get-browser/main.go:13 +0x288
#12 21.31 exit status 2
------
executor failed running [/bin/sh -c go run ./lib/utils/get-browser]: exit code: 1
@ysmood I am able to build docker image for linux/arm64
on M1 Macbook by installing chrome dependencies in base image(golang). Thank you @ARolek for fixing this issue.
I'm still working on it, works fine on my local machine, but github actions doesn't work, I still don't know why.
@ysmood have you tried using the macos hosted runner on GH actions yet? I don't think cross compiling is a good approach in this instance.
@ARolek No, because I want developers to use images that are cross built under trustable third party machines, not mine. I don't have enough donation to buy third party mac vps.
I'm still working on it, works fine on my local machine, but github actions doesn't work, I still don't know why.
For which platforms you are building on local machine? Which machine you are using as local? For me, it builds for linux/arm64
but not for linux/amd64
on M1 Macbook.
I think you can still use the GH macos runner and then push the arch specific build to the GH container registry. GitHub has this runner available as a default option with the included free tier for open source projects. It does use minutes faster than Ubuntu, but I have never had an issue I bing out of build time on other open source projects.
I'm still working on it, works fine on my local machine, but github actions doesn't work, I still don't know why.
For which platforms you are building on local machine? Which machine you are using as local? For me, it builds for
linux/arm64
but not forlinux/amd64
on M1 Macbook.
Update: After pulling your latest changes, i can successfully build docker images for linux/arm64
and linux/amd64
on local(M1 Macbook) and using github action using runner ubuntu-22.04
. I have forked go-rod repo and added another github actions for multi-arch build using ubuntu runner.
@SantoshSah The problem is I want to test the docker image before releasing it, or it will make PR able to release docker images to the rod official registry.
@ARolek GH macos doesn't support docker, I already tried it.
@ysmood GH macos does not natively support docker but we can install docker using colima and build images. I have added a GH action for multi-arch build using macos-12 runner. It works but more than 3 times slower than Ubuntu runner.
I think we can close this issue now, I have fixed the CI, just added some todo for Github Actions bugs.
On Apple silicon machines you can just pull without any tag, it will automatically choose the right image for you:
docker pull ghcr.io/go-rod/rod
Now rod images use docker manifest to support multi-arch, for example:
