我正在尝试使用dpkg在alpine图像上安装谷歌chrome稳定版。然而,dpkg已经安装,但它没有安装googlechrome-stable并返回此错误?有没有一种方法可以使用dpkg或其他方式在alpine图像中安装谷歌chrome稳定版?
dpkg: regarding google-chrome-stable_current_amd64.deb containing
google-chrome-stable:amd64, pre-dependency problem:
google-chrome-stable:amd64 pre-depends on dpkg (>= 1.14.0)
dpkg: error processing archive google-chrome-stable_current_amd64.deb (--install):
pre-dependency problem - not installing google-chrome-stable:amd64
Errors were encountered while processing:
Dockerfile:
# Base image
FROM ruby:2.6.3-alpine3.10
# Use node version 10.16.3, yarn version 1.16.0
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ nodejs=10.16.3-r0
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/community/ yarn=1.16.0-r0
# Install dependencies
RUN apk upgrade
RUN apk --update
add build-base
git
tzdata
nodejs
nodejs-npm
bash
curl
yarn
gzip
postgresql-client
postgresql-dev
imagemagick
imagemagick-dev
imagemagick-libs
chromium
chromium-chromedriver
ncurses
less
dpkg=1.19.7-r0
chromium
chromium-chromedriver
RUN dpkg --add-architecture amd64
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb
# This is the base directory used in any
# further COPY, RUN and ENTRYPOINT commands
WORKDIR /webapp
# Copy Gemfile and Gemfile.lock and run bundle install
COPY Gemfile* /webapp/
RUN gem install bundler -v '1.17.3' &&
bundle _1.17.3_ install
# Copy everything to /webapp for docker image
COPY . ./
EXPOSE 3000
# Run the application
CMD ["rails", "server", "-b", "0.0.0.0"]
以这种方式安装Chrome.deb文件在Alpine上不起作用。
虽然dpkg
包在Alpine存储库中可用,并且对于安装轻量级Debian包很有用,但您将无法使用它来安装复杂的Debian包,因为它不可能满足许多Debian依赖项。Alpine通常不兼容Debian(依赖musl-libc(,因此使用apk安装原生Alpine包是正确的方法。
AFAIK,目前还没有兼容谷歌Chrome Alpine Linux的musl-libc版本。
然而,你可以安装Chromium浏览器,它可以使用apk软件包:
apk add chromium
另一种选择是在香草Alpine映像上启用glibc,使其与Debian二进制文件兼容。这是一个相当简单的过程,请参阅:Dockerfile。然而,它可能不适合具有诸如ruby:2.6.3-alpine3.10
之类的现有应用的图像。此外,即使在Alpine上进行了glibc设置,Chrome也不太可能在没有问题的情况下运行。我做了一个快速的尝试(Dockerfile(,但没能通过第一个segfault。
编辑9/21:至少可以说,在Alpine上运行与debian兼容的Chrome稳定版将是一项非常困难的任务。这在一定程度上是由于大量的依赖项和库。尝试运行它会导致在动态链接过程中出现segfault,最后是来自动态链接器的断言。即使我们设法解决了这些问题并启动Chrome,它也可能非常不稳定。
由于chromium-chromedriver
出现在您的包列表中,我想您想做browser automation
。至于browser automation
,我使用了java
和selenium
,并手动下载了chromium
二进制和chromium driver
二进制。
我最想告诉您的是,chromium
二进制和chromium driver
二进制捆绑包可能无法按预期工作,您需要降级chrome驱动程序或chrome的版本,并进行多次尝试,以找到真正有效的匹配版本,无论您使用的是node.js还是java-selenium。
使用Selenium
,您可以选择将chrome和chromedriver捆绑包作为http服务部署在不同的服务器中,并使selenium调用远程chrome
服务。
ChromeDriver版本93.0.4577.15