How to add cypress into my current docker?
If you're using docker-compose, the cleaner solution is to just use a separate, dedicated Cypress Docker container, so your docker-compose.yml
becomes:
version: '2'services: web: build: . entrypoint: npm run dev volumes: - .:/usr/app - /usr/app/node_modules ports: - "8080:8080" cypress: image: "cypress/included:3.2.0" depends_on: - web environment: - CYPRESS_baseUrl=http://web:8080 working_dir: /e2e volumes: - ./:/e2e
The e2e
directory should contain your cypress.json
file and your integration/spec.js
file. Your package.json
file doesn't have to include Cypress at all because it's baked into the Cypress Docker image (cypress/included
).
For more details, I wrote a comprehensive tutorial on using Docker Compose with Cypress:
Running into a similar issue with a similar set up
The way I temporarily fixed it was by manually going into the folder containing my node_modules
folder and running node_modules/.bin/install
, from there you should be able to open it with node_modules/.bin/open
or $(npm bin)/cypress open
.
Tried setting up a separate cypress container on my docker-compose as such
cypress: build: context: . dockerfile: docker/cypress depends_on: - node volumes: - .:/code
with the dockerfile being Cypress's prebuilt docker-container
Was able to get docker-compose exec cypress node_modules/.bin/cypress verify
to work, but when I try to open Cypress it just hangs.
Hope this helps OP, but hope someone can provide a more concrete answer that will help us run Cypress fully through docker
You can also use an already existing cypress image on docker hub and build it in docker compose. Personnaly I avoid adding it directly in compose, I create a separate docker file for cypress.