Howto download Chromium v77 in Dockerfile with Alpine? - docker

I am currently using the node:12-alpine Docker image and I am trying to install Chromium version 77, but I am unable to figure out how as I can not find a package for it.
I am fine with changing to a different docker image if that would allow me to install Chromium version 77.
Question:
How can I download and install Chromium version 77 in a docker image?

You can use 3.x version of alpine which has Chromium v77
FROM alpine:3.10
RUN apk update && apk add --no-cache chromium
PS: I also added chromium-driver and libcanberra-gtk3 module for my requirement.

FROM alpine:3.7
RUN apk add --no-cache --virtual .build-deps curl \
&& curl -fSL https://chrome.com/chrome.tar.gz -o chrome.tar.gz
Just download it, it should be fine.
download chrome:
chrome download

Related

Cannot explain why Alpine apk upgrade command does not update ncurses package although a newer version exists

I have a Dockerfile as:
FROM nginx:1.21.3-alpine
RUN apk update && apk add bash \
&& apk upgrade
I can see that package ncurses is installed and the version is 6.2_p20210612-r0.
Now, There is a newer package available in the main repository edge branch with version 6.2_p20211002-r0 here.
As far as I understand after building an image from the above mentioned Dockerfile the version of ncurses should be updated to 6.2_p20211002-r0 BUT instead it stays as 6.2_p20210612-r0. I cannot understand why?
I confirmed this by running a container after build and running:
apk info -a ncurses
The output was:
ncurses-6.2_p20210612-r0 installed size:
284 KiB
The nginx:1.21.3-alpine image is based on Alpine 3.14 (see cat /etc/os-release), and therefore ncurses is updated with the version of the Alpine 3.14 repository, which is currently 6.2_p20210612-r0.
For installing ncurses from edge (currently version 6.2_p20211002-r0), you could specify the edge repository explicitly in the apk command:
apk add ncurses --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
Mixing and matching packages from different repositories this way might be OK in some cases, but has to be tested carefully. For ncurses, some functionality might be broken, since the matching ncurses-libs package should be installed as well, but some of the package images depend on ncurses-libs, so re-installing it triggers update of these packages. Moreover, the nginx-module-njs dependent package must be removed. If this is acceptable, you could modify the Dockerfile as follows:
FROM nginx:1.21.3-alpine
RUN apk update && \
apk del ncurses ncurses-libs nginx-module-njs && \
apk add ncurses ncurses-libs --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main && \
apk add bash && \
apk upgrade

How to add chrome browser to TestCafe docker image?

TestCafe docker image is having only chromium,firefox. I want use same image to run tests on chrome & tried to build docker image by installing chrome browser using testcafe base image (linux/amd64). But running into issues.
docker run -v ${PWD}/tests:/tests -it testcafe/testcafe chromium,firefox tests/shared/abc.js
https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/use-testcafe-docker-image.html#test-in-docker-containers
apt-get is the package manager for Ubuntu and other Debian-based distros,
apk for Alpine
for my base image type linux/amd64(https://hub.docker.com/r/testcafe/testcafe/tags?page=1&ordering=last_updated)
ERROR [2/5] RUN apk update && apk add --no-cache
ERROR [2/5] RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo dpkg -i google-chrome-stable_current_amd64.deb
Was trying like below in docker file:(Not sure exact preprequisites section & install Chrome section)
#Step 0: Choose base
FROM testcafe/testcafe
#Step 1 : Install the pre-requisite
RUN apk update
RUN apt-get install -y curl
RUN apt-get install -y p7zip
p7zip-full
unace
zip
unzip
bzip2
#Version numbers
ARG CHROME_VERSION=89.0.4389.114
#Step 2: Install Chrome
RUN curl http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_$CHROME_VERSION-1_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb
RUN rm /chrome.deb
CMD ["echo", " hello, Welcome to Kiran's custom testcafe docker image!"]
Appreciate if anyone suggest commands in docker file for this object.
Unfortunately, there seems to be no reliable way to install Google Chrome on Alpine Linux. The dpkg package used in your example is intended for Debian-based distributions. While it is available on Alpine Linux as well, it is usually good for lightweight packages only. With heavy packages, it is likely to fail because some of its dependencies are unavailable on Alpine.
That is why the apk package manager is preferred for Alpine Linux. However, google-chrome is not available for apk (only chromium is). See https://stackoverflow.com/a/58781506.
If you need to use a full-featured google-chrome for testing, please consider using a Debian-based Docker image instead of the Alpine-based TestCafe image.

Docker has no package manager

Using the image firesh/nginx-lua. After running the docker Image I want to install some things but it has no apt / apt-get or any other package manager.
I tried to install apt on the docker but it requires curl, which does not exist as well.
Any solution for that? I cannot install anything manually on this docker
Thanks..
It's because the base image used alpine, it has apk, you can use apk as apk is the default package manager on alpine. You can add things using apk add <desired_thing>, before this also do apk update.
Ex: for adding curl:
apk update
apk add curl

How can we install google-chrome-stable on alpine image in dockerfile using dpkg?

I am trying to install google-chrome-stable on alpine image using dpkg. However, the dpkg is installed but it does not install google-chrome-stable and return this error instead? Is there a way to install google-chrome-stable in alpine image either using dpkg or other way?
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"]
Installing the Chrome .deb file this way won't work on Alpine.
While the dpkg package is available in the Alpine repository, and is useful for installing lightweight Debian packages, you won't be able to use it for installing complex Debian packages, since it'll be impossible to satisfy many Debian dependencies. Alpine is generally not Debian compatible (relying on musl libc), so installing native Alpine packages using apk is the right way to go.
AFAIK, there's currently no Google Chrome Alpine Linux compatible, musl-libc build.
You could, however, install the Chromium browser, which is available using an apk package:
apk add chromium
Another option is enabling glibc on a vanilla Alpine image, making it compatible with Debian binaries. This is a fairly simple procedure, see: Dockerfile. However, it may not be suitable for images with existing applications such as ruby:2.6.3-alpine3.10. Moreover, even with a glibc setup on Alpine, Chrome is not likely to run without issues. I have made a quick attempt (Dockerfile) but couldn't get past the first segfault.
Edit 9/5/21: Running the debian compatible Chrome stable on Alpine is going to be a very difficult task to say the least. This is in part due to the very large number of dependencies and libraries. Trying to run it results with segfaults during dynamic linking and finally assertions from the dynamic linker. Even if we manage to get passed these issues and start Chrome it will probably be very unstable.
Since chromium-chromedriver is presented in your package list, I suppose that you want to do browser automation.As to browser automation, I used java and selenium, and download chromium binary and chromium driver binary manually.
What the most I want to tell you is that the chromium binary and chromium driver binary bundle might not work as expected, and you need to downgrade the version of either chrome driver or chrome and make several trial to find a matched versions that really work, no matter whether you use node.js or java selenium.
With Selenium, you have another option that you can deploy the chrome and chromedriver bundle as a http service in a different server, and make selenium invoke the remote chrome service.
ChromeDriver for version 93.0.4577.15

Php7 Redis Client on Alpine OS

I crafted a docker image using alpine 3.5 as base Image. I want my php apllication running inside container to communicate with a redis server.But I don't find any php7-redis client in Alpine.
Is there a workway around it ?I tried to use pecl to install redis but there is no pecl package in alpine.I tried with pear but pear doesn't have redis package. Any thoughts on this issue ?
For versions of Alpine prior to 3.6, such as the current official PHP Alpine image (Alpine 3.4), you need to build the extension from source. There are a few dependencies you also need to do that: autoconf, git, gcc/g++, and make. As an example, this is a complete Dockerfile for the latest stable release of PHP built on Alpine with the redis extension for php7 installed and enabled:
FROM php:alpine
RUN apk add --no-cache autoconf git g++ make
RUN \
git clone https://github.com/phpredis/phpredis.git && \
cd phpredis && \
git checkout php7 && \
phpize && \
./configure && \
make && make install && \
docker-php-ext-enable redis
If you want a smaller image you can remove the phpredis directory and the deps that were needed to clone and build it afterward. If you're not using an official PHP image then you will need to replace docker-php-ext-enable redis with a couple of commands to move the redis.so where you need it and add the extension=redis.so line to your PHP config.
You can find your solution here https://pkgs.alpinelinux.org/package/edge/community/x86_64/php7-redis
php7-redis is in v3.6 (released yesterday) and edge (rolling/unstable), as you can easily find yourself on pkgs.alpinelinux.org.
pecl is currently provided by package php7-pear.

Resources