microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.72k stars 1.4k forks source link

Headless browser (chrome/chromium/firefox) as a Feature #1648

Open snebjorn opened 2 years ago

snebjorn commented 2 years ago

I'd love if I could add a headless browser to my dev container using the dev container features.

"features": {
  "headless-chrome": "latest",
  "headless-chromium": "latest",
  "headless-firefox": "latest",
}

All (that I know) JS/TS testing frameworks need it. Manually adding it without having to resort to --no-sandbox is very complicated. I have yet to succeed at it 😞 --no-sandbox is considered insecure and strongly discouraged.

Relates to: Both

Chuxel commented 2 years ago

The "desktop-lite" script is set up to allow this kind of thing. Note that sandboxing requires running as a non-root user. It's not allowed as root since that's basically --no-sandbox. You also need to increase shared memory if you see crashes. This is described in https://github.com/devcontainers/features/tree/main/src/desktop-lite#resolving-crashes

However, if you'd like to create a feature for this, you can now contribute one that will show up in UX over the next month or so. https://github.com/devcontainers/feature-template covers how to author a feature, and to add it to an index, you can add your collection to this file: https://github.com/devcontainers/devcontainers.github.io/blob/gh-pages/_data/collection-index.yml

snebjorn commented 2 years ago

I made something and it appears to work. At least for me. It's early days and linux isn't my strong suite so I'm just throwing commands at the wall to see what sticks

Anyway https://github.com/snebjorn/devcontainer-feature/pkgs/container/devcontainer-feature%2Fchromium