seleniumhq-community / docker-seleniarm

Multi-Arch (arm64/armhf/amd64) Docker images for the Selenium Grid Server
https://hub.docker.com/u/seleniarm
Other
248 stars 24 forks source link

is it possible to install python3 and pip3 on seleniarm/standalone-chromium image #16

Closed mals14 closed 2 years ago

mals14 commented 2 years ago

What happened?

For me, this below Dockerfile works on the Mac with M1, but does not work on a Ubuntu server in the cloud. Any suggestions as to Dockerfile instructions such that docker build install python3 and pip3 on Mac M1 and on the server both?

As of now when I run this Dockerfile in the cloud, I get an error as shown in logs below. It builds and runs just fine on Mac M1.

Spent countless hours trying to make this work. I am not an expert at all but would much like this to work. Feels like I am quite close.

Thank you!

Dockerfile below:

# from https://hub.docker.com/r/seleniarm/standalone-chromium/tags
FROM seleniarm/standalone-chromium:105.0 

# install python3
USER root
RUN apt-get update -y

# instructions from https://www.rosehosting.com/blog/how-to-install-python-3-10-on-debian-11/
RUN apt-get install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y\
    && wget -c https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz\
    && tar -Jxvf Python-3.10.0.tar.xz\
    && cd Python-3.10.0\
    && ./configure --enable-optimizations\
    && make altinstall\
    && python3.10 --version

RUN apt-get install python3-pip -y

# set display port to avoid crash
ENV DISPLAY=:99

# upgrade pip
RUN pip install --upgrade pip

# Install pip requirements
COPY requirements.txt .
RUN python3 -m pip install -r requirements.txt

WORKDIR /app
COPY . /app

# During debugging, this entry point will be overridden. For more information, refer to https://aka.ms/vscode-docker-python-debug
CMD ["sh"]

Command used to start Selenium Grid with Docker

docker build . -t selenium_in_docker

Relevant log output

Sending build context to Docker daemon    171kB
Step 1/12 : FROM seleniarm/standalone-chromium:105.0
 ---> 630aafdcad50
Step 2/12 : USER root
 ---> Using cache
 ---> 6c5d935af2a6
Step 3/12 : RUN apt-get update -y
 ---> Running in 59cdf7fd5874
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian sid InRelease [192 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]
Get:6 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [182 kB]
Get:7 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B]
Get:8 http://deb.debian.org/debian sid/main amd64 Packages [9353 kB]
Fetched 18.1 MB in 3s (5974 kB/s)
Reading package lists...
E: Problem executing scripts APT::Update::Post-Invoke-Success '/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null'
E: Sub-process returned an error code
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c apt-get update -y' returned a non-zero code: 100

Operating System

Ubuntu

Docker Selenium version (tag)

seleniarm/standalone-chromium:105.0

mals14 commented 2 years ago

I figured that if I build the same thing on the Ubuntu server then I can use this Dockerfile - just the first line is changed from Seleniarm to Selenium.

Now, of course, the next question is how to make it so that the same repository can be built on the Mac or the Ubuntu server without having to have two separate Dockerfiles.

But that is not such a big deal.

FROM selenium/standalone-chrome:105.0
mals14 commented 2 years ago

Ready to close the issue because the original issue is resolved by way of using different base images on the Ubuntu server vs Mac M1. Not something that is desirable given Docker's promise of being able to work across platforms but at least it works. Leaving it here in case somebody here has additional insight to make this work without resorting to different Dockerfile documents.