Dockerfile to build and install Chromium for Alpine Linux apk from any commit ID.
Note
It takes about 4 to 12 hours to build Chromium on a typical 8-core machine.
As far as I know, the official package repository for Alpine Linux doesn't provide older versions of packages in the same branch. So, if you need an older version of Chromium from a specific branch, you must build the apk yourself. This is why this repository exists. It's here to help you easily build any version of Chromium apk using Docker, especially when the official repository doesn't have the version you need.
In most cases, you can use the Dockerfile
. You can specify the following build args:
- ALPINE_VERSION: This refers to the base Docker image version of Alpine Linux that will be used to build and install Chromium.
- COMMIT_ID: Specify the commit id from the aports repository that you want to build.
For example, to build chromium 112.0.5615.165 on alpine:3.17, you would use the following command:
docker build -t abuild-chromium --build-arg ALPINE_VERSION=3.17 --build-arg COMMIT_ID=e197e433add07f6416e0dd6cbd428256b4c5aa76 .
To build an older commit where the snapshot()
function is defined in APKBUILD, use the Dockerfile.wsnapshot as follows:
docker build -t abuild-chromium -f Dockerfile.wsnapshot .
Depending on the commit id, you may need to add a special command during the builder stage to install build dependencies that are deprecated in newer Alpine releases, like this:
apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/v3.16/community libgnome-keyring-dev
To run the built Docker image:
docker run -d --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e PULSE_SERVER=$PULSE_SERVER \
--cap-add SYS_ADMIN abuild-chromium chromium --disable-gpu --disable-dev-shm-usage --no-first-run
- the
SYS_ADMIN
capability required to run Chromium. - Use
--disable-dev-shm-usage
because Docker's /dev/shm is usually too small.
To extract the built Chromium apk and the corresponding public key for installation on other Alpine Linux environments, follow these steps:
$ container_id=$(docker run --rm -d abuild-chromium tail -f /dev/null)
$ docker cp $container_id:/opt/packages .
$ docker cp $container_id:/etc/apk/keys/ .
$ docker kill $container_id