Created
April 1, 2020 18:45
-
-
Save revmischa/cd299db577af73965ef96ee6dbd1deca to your computer and use it in GitHub Desktop.
Build chromium on amazon linux 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM lambci/lambda:build-python3.8 | |
# ref: https://chromium.googlesource.com/chromium/src.git/+refs | |
ARG VERSION | |
ENV VERSION ${VERSION:-master} | |
LABEL maintainer="Mischa Spiegelmock <[email protected]>" | |
LABEL chromium="${VERSION}" | |
WORKDIR / | |
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum-utils | |
RUN yum-config-manager --enable epel | |
RUN yum install -y \ | |
git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \ | |
bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \ | |
cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \ | |
freetype-devel gcc-c++ glib2-devel glibc.i686 gperf glib2-devel \ | |
gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel \ | |
libgcc.i686 libgnome-keyring-devel libjpeg-devel libstdc++.i686 libX11-devel \ | |
libXScrnSaver-devel libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs \ | |
nspr-devel nss-devel nss-util-devel pam-devel pango-devel pciutils-devel \ | |
pulseaudio-libs-devel zlib.i686 httpd mod_ssl php php-cli python-psutil wdiff \ | |
xorg-x11-server-Xvfb glibc-devel python-py | |
ENV LANG en_US.utf-8 | |
ENV LC_ALL en_US.utf-8 | |
WORKDIR /build | |
RUN git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
ENV PATH /opt/gtk/bin:$PATH:/build/depot_tools | |
# get chromium source | |
WORKDIR /build/chromium | |
# ADD .gclient /build/chromium/ | |
RUN fetch --no-history chromium | |
WORKDIR /build/chromium/src | |
# tweak to keep Chrome from crashing after 4-5 Lambda invocations | |
# see https://github.com/adieuadieu/serverless-chrome/issues/41#issuecomment-340859918 | |
# Thank you, Geert-Jan Brits (@gebrits)! | |
ENV SANDBOX_IPC_SOURCE_PATH "content/browser/sandbox_ipc_linux.cc" | |
RUN sed -e 's/PLOG(WARNING) << "poll";/PLOG(WARNING) << "poll"; failed_polls = 0;/g' -i "$SANDBOX_IPC_SOURCE_PATH" | |
# we need python2 to run gn/autoninja... Sad! | |
ENV PATH /usr/bin:$PATH | |
# build flags | |
RUN mkdir -p out/Headless && \ | |
echo 'import("//build/args/headless.gn")' > out/Headless/args.gn && \ | |
echo 'is_debug = false' >> out/Headless/args.gn && \ | |
echo 'symbol_level = 0' >> out/Headless/args.gn && \ | |
echo 'blink_symbol_level = 0' >> out/Headless/args.gn && \ | |
echo 'is_component_build = false' >> out/Headless/args.gn && \ | |
echo 'enable_nacl = false' >> out/Headless/args.gn && \ | |
gn gen out/Headless | |
# build chromium headless shell | |
RUN autoninja -C out/Headless headless_shell | |
WORKDIR /build | |
RUN strip -o "/bin/headless-chromium" /build/chromium/src/out/Headless/headless_shell | |
EXPOSE 9222 | |
ENTRYPOINT [ \ | |
"/bin/headless-chromium", \ | |
"--disable-dev-shm-usage", \ | |
"--disable-gpu", \ | |
"--no-sandbox", \ | |
"--hide-scrollbars", \ | |
"--remote-debugging-address=0.0.0.0", \ | |
"--remote-debugging-port=9222" \ | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment