I recently used Headless Chrome together with Selenium to test a frontend project. The results were pretty good, and adding the tests after Jenkins deployment gave at least some confidence that the frontend still worked after each release.
This post records a Dockerfile for installing Headless Chrome on Ubuntu 20.04 so I can find it again later.
1 | FROM ubuntu:20.04 |
Notes:
- The APT mirror is switched to Tsinghua’s mirror to speed up dependency installation.
DEBIAN_FRONTEND=noninteractiveis set becausetzdatamay otherwise prompt during installation and causedocker buildto hang.- Because of that non-interactive setting, the final timezone configuration is handled manually.
fonts-wqy-microheiis installed so Chinese text can render correctly, especially when exporting PDFs.- Installing Chrome with
dpkg -iis expected to fail at first because dependencies are missing, so the command ends withexit 0. apt install -f -yis then used to repair dependencies and complete the installation.