mujo-code / puppeteer-headful

Github Action for puppeteer that is headful.
MIT License
98 stars 41 forks source link

How to run it with docker-compose #131

Closed ngohuytrieu closed 4 months ago

ngohuytrieu commented 4 months ago

Hi all, I am trying to run jest-puppeteer tests with docker-compose in github actions Here is my yml file:

jobs:
  test-e2e:
    runs-on: ubuntu-latest

    env:
      PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Set up Docker Compose
        run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} up -d

      - name: Run E2E Tests
        uses: mujo-code/puppeteer-headful@16.6.0
        env:
          CI: "true"
        with:
          args: docker exec -t app npm run test:e2e-admin

      - name: Tear down Docker Compose
        run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} down

I got this error for above github action

/entrypoint.sh: 13: /entrypoint.sh: docker: not found
Running 'docker exec -t app npm run test:e2e-admin'!
jcblw commented 4 months ago

@ngohuytrieu looks like you would need to install docker, into the docker container to get this command to work. Im not sure of the implications of running docker in a docker container or your use case but would assume that the docker commands are not needed here.

Can you maybe speak more about this use case?

ngohuytrieu commented 4 months ago

@jcblw So basically, I build a node js web server using docker and docker-compose On github action CI, I want to run that docker container and run test command inside that docker container, like this:

docker exec -t app npm run test:e2e-admin

In order to do that here is my github action yml file

jobs:
  test-e2e:
    runs-on: ubuntu-latest

    env:
      PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Set up Docker Compose
        run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} up -d

      - name: Run E2E Tests
        run: docker exec -t app npm run test:e2e-admin

      - name: Tear down Docker Compose
        run: docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} down

Unfortunately, I am stuck on this for weeks because of this error

No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

Don't get me wrong, I did set --no-sandbox in puppeteer configuration but still no luck

jcblw commented 4 months ago

Yeah, this action sets up a docker image that can run Puppeteer. With what you are trying to do, you might just need some of the code from this repo to set up your docker container to run Puppeteer. I think you probably realized that by looking at the action you posted.

jcblw commented 4 months ago

closing due to inactivity @ngohuytrieu let me know if you disagree.