Docker build for CEF

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

Docker build for CEF

Postby sealemar » Fri Aug 07, 2020 2:39 pm

Hello,

I wrote an automation that builds CEF in docker for ARM64 and for x64. The automation follows this instructions https://bitbucket.org/chromiumembedded/ ... ldSetup.md with some additions. I would like to share it to public and I am thinking of putting it on my public GitHub repo. Please, let me know if you are ok with that or if you have other suggestions.
sealemar
Newbie
 
Posts: 3
Joined: Fri Aug 07, 2020 2:09 pm

Re: Docker build for CEF

Postby magreenblatt » Fri Aug 07, 2020 3:02 pm

Thanks for sharing :) I think that would be great.

If you choose a compatible license (like MIT or 3-clause BSD) then we can potentially use it as the basis for an officially supported docker configuration in the future.
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm

Re: Docker build for CEF

Postby sealemar » Fri Aug 07, 2020 3:30 pm

Thank you for a quick response. The MIT license is exactly what I had in mind for that. Let me run docker build for both ARM64 and x64 one more time and fill in the README.md appropriately. I will update this thread once everything is ready. It will not be immediate, since each build takes many hours.
sealemar
Newbie
 
Posts: 3
Joined: Fri Aug 07, 2020 2:09 pm

Re: Docker build for CEF

Postby sealemar » Mon Aug 10, 2020 5:49 pm

Here is that repo in public domain https://github.com/sealemar/cef-dockerized. I ran it one more time for ARM64 and x64 to make sure it works. I published it under MIT License. Please, let me know if you have questions or concerns.
sealemar
Newbie
 
Posts: 3
Joined: Fri Aug 07, 2020 2:09 pm

Re: Docker build for CEF

Postby magreenblatt » Tue Aug 11, 2020 2:47 pm

Thanks for posting the link. A few questions/observations:

  • It looks your Dockerfile contains both RUN and CMD instructions that will generate a build. I wonder if it would make sense to split the setup and build logic so that the docker image can be shared (via `docker pull`, etc) after the setup steps and before the build steps. In that case, perhaps the RUN instruction should install the deps and download the automate-git.py script, and the CMD or ENTRYPOINT instruction should call automate-git.py to download and build Chromium/CEF.
  • Users may wish to customize the GN_DEFINES environment variable and automate-git.py command-line arguments, or run just a Debug or Release build. It would be good to expose those configuration options.
  • Users may wish to develop using incremental builds by running just the `cef_create_projects.sh` and `ninja` commands in an already existing container.
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm

Re: Docker build for CEF

Postby magreenblatt » Tue Aug 11, 2020 2:56 pm

Another potential use case is someone who already has a Chromium src/ checkout that they're using for development. They might want to have a docker container that references the existing src/ checkout but writes build artifacts to a different/unique output directory. For example, to test alternative build environments (like use_sysroot=true vs false) using a separate docker container to represent each environment.

(Note: I'm not suggesting that we have to support all of these use cases with the same docker setup, but it's something to think about.)
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm

Re: Docker build for CEF

Postby magreenblatt » Tue Aug 11, 2020 3:09 pm

magreenblatt wrote:Another potential use case is someone who already has a Chromium src/ checkout that they're using for development.

They might also want to have the Chromium checkout and build directories separate from the docker image for other reasons, such as available disk space or performance.
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm

Re: Docker build for CEF

Postby magreenblatt » Tue Nov 17, 2020 3:35 pm

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
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm

Re: Docker build for CEF

Postby magreenblatt » Wed Sep 20, 2023 1:41 pm

Update for CEF M118

1. We've been experiencing some issues with "git clone" when using "debian:latest", which is currently bookworm:
fatal: unable to access 'https://chromium.googlesource.com/chromium/tools/depot_tools.git/': getaddrinfo() thread failed to start

This can be avoided by explicitly pinning "debian:bullseye".

2. Chromium has switched install scripts from install-build-deps.sh to install-build-deps.py.

Docker files are updated as follows:

Dockerfile contents:
Code: Select all
FROM debian:bullseye

# 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.
# This isn't strictly required since the `build-in-docker` script will run with
# the `--user` command-line argument, but it adds safety by default.
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=118.0.5993.0

# Packages required to download and run the Chromium bootstrap.
apt-get update
apt-get install -y \
    curl \
    file \
    lsb-release \
    python3

# Download the Chromium bootstrap at the requested version.
curl "https://chromium.googlesource.com/chromium/src/+/refs/tags/${chromium_version}/build/install-build-deps.py?format=TEXT" | base64 -d > install-build-deps.py

# 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 32-bit and ARM dependencies included.
# NOTE: Installing locales fails, but we ignore the error.
python3 ./install-build-deps.py --lib32 --arm --no-chromeos-fonts --no-nacl --no-prompt

# Install pgrep which is used by depot_tools/.cipd_bin/goma_ctl.py.
apt-get install -y procps

# 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 to reduce image size.
apt-get purge -y --auto-remove
magreenblatt
Site Admin
 
Posts: 12744
Joined: Fri May 29, 2009 6:57 pm


Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 2 guests