I need to package a Scala app that handles REST API call and in some cases launches FireFox browser with help of Selenium WebDriver. I use sbt-native-packager, since it's convenient and simple. As a base image I use own Dockerfile:
# https://hub.docker.com/_/debian
FROM openjdk:8-jre-alpine3.9
ARG firefox_ver=70.0
ARG geckodriver_ver=0.26.0
# Download and install deps
RUN apk update && apk add curl curl-dev
# Download and install Firefox
RUN curl -fL -o /tmp/firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/${firefox_ver}/linux-x86_64/en-GB/firefox-${firefox_ver}.tar.bz2 \
&& tar -xjf /tmp/firefox.tar.bz2 -C /tmp/ && mv /tmp/firefox /usr/local/bin/
# Download and install geckodriver
RUN curl -fL -o /tmp/geckodriver.tar.gz \
https://github.com/mozilla/geckodriver/releases/download/v${geckodriver_ver}/geckodriver-v${geckodriver_ver}-linux64.tar.gz \
&& tar -xzf /tmp/geckodriver.tar.gz -C /tmp/ && chmod +x /tmp/geckodriver && mv /tmp/geckodriver /usr/local/bin/
ENV PATH="/usr/local/bin/firefox:${PATH}"
And then in build.sbt
I use following command in order to provide an appropriate access level to the firefox
binary:
...
dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/usr/local/bin/firefox/firefox")
...
But unfortunately when I connect to the running docker container and try to call the firefox
, I get this:
/opt/docker $ firefox
sh: firefox: Permission denied
As a result, the Scala app is not able to launch FireFox as well :(
Here is permission of the firefox
:
-rwxr-xr-x 1 root root 14656 Oct 16 17:55 firefox
It seems you cannot run (this version of) firefox on Alpine:
# ldd firefox
/lib64/ld-linux-x86-64.so.2 (0x7fcc15ef4000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fcc15ef4000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fcc15ef4000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fcc15d9f000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fcc15ef4000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fcc15d8b000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fcc15ef4000)
Error relocating firefox: __fprintf_chk: symbol not found
This seems to be caused by Alpine being based on musl instead of GNU libc.
To work around, you could use the firefox package available from Alpine itself (but you would still need the geckodriver to work too)... Alternatively, switch to the non-alpine Docker image.