I ended up taking a slightly different approach, where the docker image only installs the necessary dependencies and the actual build is handled via a command line like:
- Code: Select all
docker run <docker-flags> -e GN_DEFINES=is_official_build=true -e CEF_ARCHIVE_FORMAT=tar.bz2 -v /host/path/to/build:/build <docker-image> /build/automate-git.py --download-dir=/build/chromium_git --depot-tools-dir=/build/depot_tools <automate-flags>
Alternately, the environment variables and automate-git.py command line can be placed in a shell script executed by the `docker run` command.
The recommended environment variables and automate flags for building different architectures are documented on the
AutomatedBuildSetup Wiki page.
Dockerfile contents:
- Code: Select all
FROM debian:latest
# Required otherwise the following RUN instruction would fail at the first chmod
# with 'missing operand'. See https://serverfault.com/a/960335/320690
USER root
SHELL ["/bin/bash", "-c"]
# Copy the install directory into the image.
COPY install/ /app/install
# Install Chromium dependencies.
RUN chmod +x /app/install/*.sh && \
/app/install/install.sh
# Continue to the default entrypoint as a non-root user.
RUN groupadd -g 999 appuser && \
useradd -r -u 999 -g appuser appuser
USER appuser
install/install.sh contents:
- Code: Select all
#!/bin/bash -x
chromium_version=109.0.5414.0
# Packages required to download and run the Chromium bootstrap.
apt-get update
apt-get install -y \
curl \
lsb-release \
python
# Download the Chromium bootstrap at the requested version.
curl "https://chromium.googlesource.com/chromium/src/+/refs/tags/${chromium_version}/build/install-build-deps.sh?format=TEXT" | base64 -d > install-build-deps.sh
chmod 755 install-build-deps.sh
# Remove the "Installing locales" step which fails with sed errors.
# TODO: This trims all the way to end-of-file. Fix the sed error or
# add a more nuanced approach in the future if necessary.
line_num="$(grep -n 'echo \"Installing locales.\"' install-build-deps.sh | head -n 1 | cut -d: -f1)"
sed -i "${line_num},\$ d" install-build-deps.sh
# The install script expects sudo, so make a placeholder that transparently forwards commands.
if type sudo 2>/dev/null; then
echo "The sudo command already exists... Skipping.";
else
echo -e "#!/bin/bash\n\${@}" > /usr/sbin/sudo;
chmod +x /usr/sbin/sudo;
fi
# Install with i386 and ARM dependencies included.
./install-build-deps.sh --lib32 --arm --no-chromeos-fonts --no-nacl --no-prompt
# Fix the following error with i386 and ARM builds:
# ././v8_context_snapshot_generator: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory
apt-get install -y libglib2.0-0:i386
# Install xvfb-run which is used for running CEF unit tests.
apt-get install -y xvfb
# Install python dependencies required by Chromium.
apt-get install -y python3-pip
python3 -m pip install \
dataclasses \
importlib_metadata
# Install Doxygen which is used to generate CEF API documentation.
apt-get install -y doxygen
# Cleanup packages to reduce image size.
apt-get purge -y --auto-remove