Put together a quick Dev Container feature that I’m hoping to share with the community.
Background
I needed a headless browser instance for running the Lighthouse CLI from within a Docker container. I thought I could get a quick one setup for Dev Containers, but it turns out there wasn’t an easy way to get headless chromium installed onto a Dev Container.
So I made a feature request on the devcontainers-contrib/features repository.
[Feature Request]: chromium-apt-get #626.
I wasn’t even the first person to ask for something like this, at least, in the broader community: [Feature] Headless browser (chrome/chromium/firefox) devcontainers/features#189
The Feature
DevContainers work by installing features in layers through their devcontainers.json specification. We just needed to get it in there.
I added a pull request that describes the whole thing here: Pull Request #627.
You can use this feature like so:
1 | "features": { |
📖 Context
There are some historical reasons for why it’s being done this way:
- The official Chromium team doesn’t supply “stable” binaries of Chromium; they are usually compiled into stable versions by third-parties.
- Chromium installation breaks when installed with
snap
packages on Ubuntu. apt-get install -y chromium
on Ubuntu 20.04+ is just a wrapper for asnap
installations.- Referenced this guide to find a reliable PPA: How to Install Chromium Browser via PPA in Ubuntu 20.04, 20.10 - credit to UbuntuHandbook.
⚖️ Caveats
The maintainers may wish to scrutinize the default PPA used here, both for security and stability concerns. I agree!
I think future improvement to this feature could include:
- Parameterizing the selected PPA to allow sourcing
chromium
binaries from public and private PPAs.
Next Steps?
Now, all that’s left is to wait for the pull request to be reviewed and then I can go ahead and mark this one as done.