Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Forked from jakub300/run.sh
Last active April 18, 2020 09:00
Show Gist options
  • Save pojntfx/b2cd40494ec22b5577f1054fb0304aa7 to your computer and use it in GitHub Desktop.
Save pojntfx/b2cd40494ec22b5577f1054fb0304aa7 to your computer and use it in GitHub Desktop.
Compile headless shell (Chromium)
# Based on:
# http://www.zackarychapple.guru/chrome/2016/08/24/chrome-headless.html
# https://www.chromium.org/developers/how-tos/get-the-code
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
# https://gist.github.com/jakub300/dc31866cb8e3cf4e135dd623ca2e2b81
mkdir -p /tmp/out
docker run --name chromium-build -it debian bash
apt update
apt install -y curl git htop man unzip vim wget python pkg-config file lsb-release
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:`pwd`/depot_tools
mkdir Chromium && cd Chromium
fetch --no-history chromium
cd src
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
./build/install-build-deps.sh --no-prompt --no-arm
gclient runhooks
mkdir -p out/Headless
echo 'import("//build/args/headless.gn")' > out/Headless/args.gn
echo 'is_debug = false' >> out/Headless/args.gn
gn gen out/Headless
ninja -C out/Headless headless_shell
exit
docker cp chromium-build:/Chromium/src/out/Headless/headless_shell /tmp/out/headless_shell
docker run --name chromium-runner -p 9222:9222 -it debian:buster-slim bash
docker cp /tmp/out/headless_shell chromium-runner:/bin/
apt update
apt install -y libnss3 libexpat1 libfontconfig
/bin/headless_shell --no-sandbox --disable-software-rasterizer --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --disable-gpu --headless --use-fake-device-for-media-stream --use-fake-ui-for-media-stream=1 --disable-dev-shm-usage
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/tmp/asdf --disable-web-security --allow-running-insecure-content http://192.168.0.28:9222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment