From 66da7160627d47cd4576b9c41e4817d2137d2241 Mon Sep 17 00:00:00 2001 From: Alex Yong Date: Tue, 15 Aug 2023 14:22:11 -0400 Subject: [PATCH] Update README.md to talk about non-root user for firefox per #938 in the github-action repo (#900) * Update README.md * Update README.md * Update README.md Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> * Update README.md --------- Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Co-authored-by: Cacie Prins --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 3fdc9db774..9e00e612dc 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,49 @@ export _MITSHM=0 See [issue #270](https://github.com/cypress-io/cypress-docker-images/issues/270) +## Firefox not found + +By default, the containers run with the root user. However, Firefox by design cannot run with root user, leading to failures such as: + +``` +Browser: firefox was not found on your system or is not supported by Cypress. +Can't run because you've entered an invalid browser name. +``` + +To resolve this, the container needs to run with user id `1001`. + +One example using the [cypress-io/github-action](https://github.com/cypress-io/github-action) + +```yml +name: E2E in custom container +on: push +jobs: + cypress-run: + runs-on: ubuntu-22.04 + container: + image: cypress/browsers:node18.12.0-chrome106-ff106 + options: --user 1001 + steps: + - uses: actions/checkout@v3 + - uses: cypress-io/github-action@v5 + with: + browser: firefox +``` + +Or within a Dockerfile + +```Dockerfile +# Use Cypress base image +FROM cypress/browsers:node18.12.0-chrome106-ff106 + +# Change to a non-root user +USER 1001 + +#rest of your dockerfile here +``` + +The [GitHub Actions Runner](https://github.com/actions/runner) creates the `/github/home` (`$HOME`) directory with non-root ownership `1001` (`runner`). Specifying this same user allows Cypress to detect and run Firefox. + ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md)