Well with much searching and pulling bits of info from various websites I did manage to get it *working*
There was a big BUT though, you need to add the --no-sandbox
option to chrome, I can’t remember which one of these worked, but it was one of them, in the end I never used it:
# ${BROWSER} Headless Chrome --no-sandbox
# ${BROWSER_OPT} options=add_argument("--no-sandbox")
I did this quite a while ago so the versions are quite old and I had trouble getting it to work with newer versions too, in the end I gave up with it as the --no-sandbox
was a deal breaker for my purposes (I was wanting to create rfswarm-agent docker images to support >10 robots)
If you still want to continue this is what I had working, from what I understand the trick was setting the screen resolution and using Xvfb to create a virtual xwindows environment so that the browser could run:
Dockerfile:
FROM python:3.7-alpine3.9
ENV SCREEN_WIDTH 1280
ENV SCREEN_HEIGHT 720
ENV SCREEN_DEPTH 16
ENV DEPS="\
chromium \
chromium-chromedriver \
udev \
xvfb \
"
COPY requirements.txt /tmp/requirements.txt
COPY entry_point.sh /opt/bin/entry_point.sh
RUN apk update ;\
apk add --no-cache ${DEPS} ;\
pip install --no-cache-dir -r /tmp/requirements.txt ;\
# Chrome requires docker to have cap_add: SYS_ADMIN if sandbox is on.
# Disabling sandbox and gpu as default.
sed -i "s/self._arguments\ =\ \[\]/self._arguments\ =\ \['--no-sandbox',\ '--disable-gpu'\]/" $(python -c "import site; print(site.getsitepackages()[0])")/selenium/webdriver/chrome/options.py ;\
# List packages and python modules installed
apk info -vv | sort ;\
pip freeze ;\
# Cleanup
rm -rf /var/cache/apk/* /tmp/requirements.txt
ENTRYPOINT [ "/opt/bin/entry_point.sh" ]
entry_point.sh:
#!/bin/sh
GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"
Xvfb :99 -screen 0 $GEOMETRY &
export DISPLAY=:99
robot "$@"
requirements.txt
robotframework==3.1.1
robotframework-selenium2library==3.0.0
robotframework-seleniumlibrary==3.3.1
selenium==3.141.0
Hopefully you find this useful,
Dave.