Giter Site home page Giter Site logo

cypress-io / cypress-docker-images Goto Github PK

View Code? Open in Web Editor NEW
992.0 992.0 373.0 1.39 MB

Docker images with Cypress dependencies and browsers

Home Page: https://on.cypress.io/continuous-integration

License: MIT License

Shell 12.24% JavaScript 10.90% Dockerfile 76.85%
cypress docker docker-image

cypress-docker-images's Introduction

Cypress Docker Images CircleCI

Cypress Docker images are published to Cypress on Docker Hub.

These images provide all of the required dependencies for running Cypress in Docker.

We build four images: click on the image name to see the available tags and versions. We provide multiple tags for various operating systems and specific browser versions. These allow you to target specific combinations you need.

Image Name Description Monthly pulls
cypress/factory A base image template which can be used with ARGs to create a custom docker image. Docker Pulls
cypress/base All operating system dependencies, no Cypress, and no browsers. Docker Pulls
cypress/browsers All operating system dependencies, no Cypress, and some browsers. Docker Pulls
cypress/included All operating system dependencies, Cypress, and some browsers installed globally. Docker Pulls

Tag Selection

If no tag is specified, for example cypress/included, then the tag latest is used by default: cypress/included:latest. It is however recommended to use a specific image tag to avoid breaking changes when new images are released, especially when they include new major versions of Node.js or Cypress.

Some examples with specific tags including an explanation of the tag meanings are:

Once an image with a specific version tag (except latest) has been published to Cypress on Docker Hub it is frozen. This prevents accidental changes.

When a new version is published, an image copy with the latest tag is also published. This means that the Docker image selected using the latest tag (or selected by default if no tag is specified) will also change over time. Specify an explicit version, for example cypress/base:18.16.0, to access instead a frozen version.

📍Cypress Docker images are offered as a convenience measure. The goal is to offer Node.js, Browser and Cypress versions to streamline running tests in CI or other non-public, sandboxed environments.

Some preparations and optimizations are not included. For example, given the near infinite permutations, images are not monitored for security vulnerabilities. Additionally, once images are published they are considered immutable and cannot be patched. That means (hypothetically) older images could become more vulnerable over time.

This means they should not be used for production deployment and security scans should be performed as-needed by users of these images.

Docker Hub

All of the images and tags are published to Cypress on Docker Hub under:

Cypress/Factory

Don't see the exact combination of Cypress, Node.js and browser versions you need for your test environment? Checkout our cypress/factory. You can use it to generate a custom image to fit your needs.

Examples

These images have all dependencies necessary to install and run Cypress. Just install your npm dependencies (including Cypress) and run the tests. We utilize many of these docker images in our own projects, with different CI providers.

Check out our docs for examples.

If you want to use the cypress/included image, read Run Cypress with a single Docker command

Common problems

Cannot run post-install hook

Some versions of Node.js restrict running the postinstall hook with the following error message:

lifecycle [email protected]~postinstall: cannot run in wd [email protected]

In that case run install with npm install --unsafe-perm flag, or set an environment variable in the container

npm_config_unsafe_perm: true

Blank screen in Chrome

When running headed tests with X11 forwarding in Cypress v4 you might see a blank Chrome screen. Try disabling memory sharing by setting the following environment variables:

export QT_X11_NO_MITSHM=1
export _X11_NO_MITSHM=1
export _MITSHM=0

See issue #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

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

# 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 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

License

See LICENSE

cypress-docker-images's People

Contributors

12 avatar admah avatar astone123 avatar atofstryker avatar bahmutov avatar bluewinds avatar brian-mann avatar cacieprins avatar chrisbreiding avatar dankreiger avatar dlgshi avatar eiel avatar emilyrohrbough avatar flotwig avatar jennifer-shehane avatar jordanpowell88 avatar kuceb avatar magcho avatar mike-plummer avatar mikemcc399 avatar mjhenkes avatar mschile avatar mtlynch avatar ryanthemanuel avatar rybon avatar sj-e2digital avatar tbiethman avatar travnels avatar vaibsaraswat avatar wtanna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cypress-docker-images's Issues

Update Node 10 docker image to lts

A week ago NodeJS 10.13 was tagged as lts, we upgrade our codebase but cypress/base becomes outdated.
Update the Dockerfile of cypress/base:10 to get node:10.13

Use separate user

For security, create separate user for installing and running Cypress

cypress/base npm version outdated

I got some errors when trying to use the cypress/base because it still installs npm v5.7. This is the error message:

�[91mnpm�[0m�[91m ERR! write after end
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] timespan has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=timespan&version=2.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://nodesecurity.io/advisories?search=minimatch&version=0.2.14 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://nodesecurity.io/advisories?search=minimatch&version=0.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m �[0m�[91mWARN �[0m�[91mnotice [SECURITY] open has the following vulnerability: 1 critical. Go here for more details: https://nodesecurity.io/advisories?search=open&version=0.0.5 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm WARN notice [SECURITY] tunnel-agent has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=tunnel-agent&version=0.4.3 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm �[0m�[91mWARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=debug&version=3.0.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=3.10.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=3.7.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m �[0m�[91mWARN�[0m�[91m �[0m�[91mnotice�[0m�[91m [SECURITY] hoek has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=hoek&version=2.16.3 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=4.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=4.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=0.9.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=0.9.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=2.4.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91mnpm�[0m�[91m WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=4.17.4 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
�[0m�[91m
�[0m�[91mnpm�[0m�[91m ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-06-12T11_48_56_365Z-debug.log
�[0mThe command '/bin/sh -c npm install' returned a non-zero code: 1

I solved this by manually installing a new npm version in my Dockerfile:

FROM cypress/base

WORKDIR /usr/src/app

# Copy the application
COPY stuff.......

# Install new version of npm because cypress has 5.7
RUN npm install -g npm
RUN npm install

CMD npm run start

Shouldn't Cypress just use the latest version of npm?

Can't export report file to host container

I'm using Cypress in a CI fashion where I run my tests. This works fine, but I need a way to export the /test-results.xml file to the host container. Is there a way to do this or a best practice for it? I cannot use docker cp because I don't know the id of the container while it is running due to my CI provider's limitations.

Why no cyress pre-installed in the dockerfile

May I ask why there is no cypress pre-installed in any of the dockerfile?
I'm why not add a line like

RUN npm install -g cypress

in the dockerfile?
I found the cypress binary will be downloaded and unzipped every time I run the test (a new container will be built for every new test), I think it's a bit of waste. Wo can you tell me why not install the cypress in the official docker images?

Update image to use Node 8

After asking on the Gitter channel, @bahmutov asked me to report this here.

Discussion transcript:

Hugo Giraudel @HugoGiraudel_twitter 16:18
Hey there. Are you planning on updating this to Node 8: https://github.com/cypress-io/cypress-docker-images?

Gleb Bahmutov @bahmutov 17:27
Hi @HugoGiraudel_twitter ! Yes, we do plan, but right now we match our dev environment to Electron's Node version (which because we are not at latest is Node 6). For consistency, as soon as Electron includes Node 8 we will upgrade our dev setup to Node 8 and then it makes sense to upgrade Docker image to include 8
Please open an issue in cypress-docker-images for this - and get notified as soon as it happens

Cypress GUI

Hello,

Is it possible to run Cypress GUI from inside the container?
My development environment is dockerized but I would still love to use your brilliant GUI.

Thanks

cypress/browsers for centOS

Anyone working on it?

I have a really urgent demand for it on the company I'm working right now and may try to tackle this if it is possible.

Is there any contributing guidelines that I should follow?

Running tests in chrome is not working

I am running my tests in chrome using -b chrome locally and I want to do the same in my pipeline but the images don't have chrome installed. When I install chrome into the image, I still get a failure.

cypress docker images won't copy ./cypress directory

When attempting to copy my cypress directory the cypress image doesn't seem to want to acknowledge that the cypress directory exists. I can rename the directory and its picked up with no issue.

amdingo@PC:/project$ docker build -t dingo/cypress -f cypress.Dockerfile .
Sending build context to Docker daemon  68.11MB
Step 1/8 : FROM cypress/browsers:chrome65-ff57
 ---> f6a9e90c31df
Step 2/8 : RUN mkdir /usr/src/app
 ---> Using cache
 ---> efa131325901
Step 3/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> f9649ac7dd00
Step 4/8 : RUN npm install [email protected]
 ---> Using cache
 ---> 16de63964510
Step 5/8 : RUN npm install faker
 ---> Using cache
 ---> 96a572132ab3
Step 6/8 : COPY cypress /usr/src/app/cypress
COPY failed: stat /var/lib/docker/tmp/docker-builder196847436/cypress: no such file or directory

rename cypress to cypress_ci

amdingo@PC:/project$ mv ./cypress ./cypress_ci

Here I change step 6 to copy the new directory instead of cypress

amdingo@PC:/project$ vi cypress.Dockerfile

and run the docker build again

amdingo@PC:/project$ docker build -t cypress -f cypress.Dockerfile .
Sending build context to Docker daemon   70.4MB
Step 1/8 : FROM cypress/browsers:chrome65-ff57
 ---> f6a9e90c31df
Step 2/8 : RUN mkdir /usr/src/app
 ---> Using cache
 ---> efa131325901
Step 3/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> f9649ac7dd00
Step 4/8 : RUN npm install [email protected]
 ---> Using cache
 ---> 16de63964510
Step 5/8 : RUN npm install faker
 ---> Using cache
 ---> 96a572132ab3
Step 6/8 : COPY cypress_ci /usr/src/app/cypress
 ---> 1fc2aa73a66e
Step 7/8 : COPY cypress.json /usr/src/app/cypress.json
 ---> 51cbeecca047
Step 8/8 : RUN ./node_modules/.bin/cypress verify
 ---> Running in 9d6bd7de15f7

edit because markdown is hard :(

Permissions issue with separate user cypress

If we create a separate user cypress, even after giving him permissions to /usr/local ... the cypress install still fails with

Step 4/7 : RUN cypress install
 ---> Running in a0b7ddd0e0f2
internal/streams/legacy.js:59
      throw er; // Unhandled stream error in pipe.
      ^

Error: EACCES: permission denied, open './cypress.zip'
    at Error (native)

The command '/bin/sh -c cypress install' returned a non-zero code: 1

Base image Dockerfile https://github.com/cypress-io/docker/blob/7af1395af2121b3d1a3c893e3f9aa51efef9c978/Dockerfile
and the Cypress install test Dockerfile
https://github.com/cypress-io/docker/blob/7af1395af2121b3d1a3c893e3f9aa51efef9c978/test/Dockerfile

Specifying USER in cypress:base image causes trouble for downstream

Just noticed that recently we changed the default user to 'person' for cypress/base:8 image.

RUN chown person /usr/local/lib/node_modules
# give new user permission to install global tools
RUN chown person /usr/local/bin
# now run as the new "non-root" user
USER person
WORKDIR /home/person

The initial motivation is good but effectively creates problems downstream.
Imagine a typical Dockerfile for a cypress project:

FROM cypress/base:8

# default /home/person doesn't make sense as workdir 
# since some hidden files with dot prefix may implicitly changed user behaviors
WORKDIR /home/person/cypress

# copied file owner will be root
COPY . /home/person/cypress

# have to switch back to root user or the next chown command would fail
USER root
RUN chown -R person /home/person/cypress

# switch back
USER person

RUN npm install

CMD ["npm", "test"]

As the above Dockerfile shows, it is really chaotic with the addition of USER person.

I would propose leaving the safety considerations back to user land, giving recommendations instead of dictating a user implicitly in a base image.

Without the USER person it could be like this:

FROM cypress/base:8

# run as non-root user inside the docker container
# see https://vimeo.com/171803492 at 17:20 mark
RUN groupadd -r regular-users && useradd -m -r -g regular-users person

# give new user access to global NPM modules folder
RUN chown person /usr/local/lib/node_modules
# give new user permission to install global tools
RUN chown person /usr/local/bin

WORKDIR /home/person/cypress
COPY . /home/person/cypress
RUN chown -R person /home/person/cypress

# run as person afterwards
USER person

RUN npm install
CMD ["npm", "test"]

Timed out waiting for the browser to connect

Hi,

I'm trying to run cypress run --browser chrome in cypress/browsers:chrome62 image but seems that chrome is not starting. Do you know what the problem could be?

Dockerfile.:

FROM cypress/browsers:chrome62

COPY containers/ci/files /
COPY apps/ci/package.json /apps/ci/package.json

USER root
RUN chown -R person /apps/ci
USER person

RUN set -x \

    # Install node modules
    && cd /apps/ci \
    && npm install

RUN set -x \
    # Create directory structure for saving results
    && mkdir -p /apps/ci/results

COPY apps/ci/ /apps/ci

USER root
RUN chown -R person /apps/ci
USER person

Stacktrace:

person@1adbaed2497a:/apps/ci$ npm run cypress:run
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info lifecycle @~precypress:run: @
npm info lifecycle @~cypress:run: @

> @ cypress:run /apps/ci
> cypress run --browser chrome

Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

  (Tests Finished)

  - Tests:           0
  - Passes:          0
  - Failures:        1
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.0.3


  (All Done)


npm info lifecycle @~cypress:run: Failed to exec cypress:run script
npm ERR! Linux 4.9.49-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cypress:run"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ cypress:run: `cypress run --browser chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ cypress:run script 'cypress run --browser chrome'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cypress run --browser chrome
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/ci/npm-debug.log

Image of chrome69 cannot find HTML elements

CI : Bitbucket

package.json

"scripts": {
    "cypress:start": "cypress run --browser chrome"
}
[bitbucket-pipelines.yml]

image: cypress/browsers:chrome69
options:
  max-time: 20
pipelines:
  default:
    - step:
        script: 
          - npm install
          - npm run cypress:start
        artifacts:
          - /opt/atlassian/pipelines/agent/build/cypress/**

Everything starts fine, but the problem is with finding HTML elements in the chrome browser.
I have a few different tests and everywhere is the same problem with finding proper classes or id's.

The error which I got looks like:

CypressError: Timed out retrying: Expected to find element: '[id*=Login]', but never found it.

I also tried loading an image of chrome with the different versions - the same situation.
Locally (chrome) and with the electron on CI everything is fine.
I think, that problem maybe is with the docer image. Did anyone have a similar issue?

*Even artifacts doesn't load to the Bitbucket - but the information, that artifacts will be deleted in 6 days is displayed

Pre-cache cypress binaries

I imagine we would maintain multiple images, one for each Cypress release, so only one Cypress binary per image.

Confirm Chrome tests run locally on OSX

Run chrome docker container locally on Mac to confirm that browser connects successfully.
Maybe add Buildkite Mac CI tests.

Needs VNC too look into the container; what is going there.

ALSA lib confmisc.c:768:(parse_card) cannot find card '0'

Hi,

Using all images that you have provided I get the following error:

  Test 1 - Desktop
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default

My configuration is:

  1. DockerFile:
FROM cypress/base:10
RUN npm install --save-dev cypress
  1. docker run command:
docker run -it -v=mye2e:mye2e -w="mye2e" <container name> /node_modules/cypress/bin/cypress run

Is there anything we need to do to surpass this problem?

Permission denied on mkdir .../cypress/dist when installing globally

We're using the docker image to avoid having to install cypress on every build.

Our docker image only runs this:

FROM cypress/base

RUN npm install -g cypress

We've used this to install cypress fine, then we could use it in our tests.

I've just tried running the build command for this docker, but we're now getting permission denied errors.

Step 3/3 : RUN npm install -g cypress // step 3 as I removed the maintainer line above
 ---> Running in 4a4330ea5831
/usr/local/bin/cypress -> /usr/local/lib/node_modules/cypress/bin/cypress

> [email protected] postinstall /usr/local/lib/node_modules/cypress
> node index.js --exec install

EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cypress/dist'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-17T14_22_58_013Z-debug.log
The command '/bin/sh -c npm install -g cypress' returned a non-zero code: 1

Has anything changed that could have caused this? We can create the folder manually, but it's still failing.

Make a base image for Centos7

Seems we cannot run on Centos7 cypress-io/cypress#819

Need to make a base image

notes

If Cypress reports a missing dependency when running cypress verify like

/usr/lib/node_modules/cypress/dist/Cypress/Cypress: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

then we can find it using yum, for example

yum whatprovides "libgtk-x11-2.0"
gtk2-2.24.31-1.el7.i686 : The GIMP ToolKit (GTK+), a library for creating GUIs for X
Repo        : base
Matched from:
Provides    : libgtk-x11-2.0.so.0

gtk2-2.24.31-1.el7.x86_64 : The GIMP ToolKit (GTK+), a library for creating GUIs for X
Repo        : base
Matched from:
Provides    : libgtk-x11-2.0.so.0()(64bit)

Then install appropriate package using

yum install -y gtk2-2.24*

Additional resources

Chrome 69 as default chrome image

Hi there!
Chrome 69 is the new version of stable chrome. In order to have consistency with CI (example, circleCI browsers are 69 now), rebuilding the images may be necessary, and retagged (as the current is cypress/browsers:chrome67).
Thanks for your work,
W.

XVFB timed out

Hey,

I am trying to setup test environment which can be run on CircleCI. Locally, everything works fine, however, when tried to tied up everything and run it on CI environment I am getting following problem:

^@^@XVFB exited with a non zero exit code.

There was a problem spawning Xvfb.

This is likely a problem with your system, permissions, or installation of Xvfb.
----------

Error: _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
----------

Platform: linux (Debian - 8.10)
Cypress Version: 3.1.0
Exited with code 1

Any idea how to solve this? Docker setup is quite straightforward, I've got three nodes apps running in parallel + mongodb + cypress in image:

Cypress Dockerfile:

FROM cypress/base:10

RUN mkdir /usr/src/app
WORKDIR /usr/src/app

RUN yarn add [email protected]

COPY cypress.json /usr/src/app/cypress.json

RUN ./node_modules/.bin/cypress verify

Cypress part in docker-compose:

  cypress:
    user: root
    volumes:
      - ./e2e:/usr/src/app/e2e
    build:
      context: .
      dockerfile: compose/cypress/Dockerfile
    network_mode: 'host'
    depends_on:
      - api

And I am firing tests by running docker-compose -f docker-compose.e2e.yml run cypress ./node_modules/.bin/cypress run. As I said, locally it's fine, but CI environment fails with error shared above.

I've also tried another solution - I wanted to use cypress node 10 image as base image for CircleCI and then run tests without docker, however, I need to run my apps from docker-compose and cypress image does not provide sudo and docker-compose as well.

Update Node 8 Image

I'm running into some issues here because I am using Cypress for testing and the coverage tool from Codacy has a dependency that requires Node >=8.12.0. From what I see, it looks like your base:8 image is at v8.11.3.

Is it possible to upgrade it to the lastest 8 version. Happy to submit a PR if I'm pointed in the right direction.

Browser: 'firefox' was not found on your system.

Hi, try to use docker image with FF browser, but get these error.
My Dockerfile:

FROM cypress/browsers:chrome67-ff57
RUN mkdir /crm2
COPY node_modules /crm2/node_modules
COPY cypress /crm2/cypress
COPY cypress.json /crm2/cypress.json
WORKDIR /crm2/
RUN npm i cypress
RUN firefox --version
RUN $(npm bin)/cypress run --record --key _mykey_  --browser firefox

Error:

Step 9/10 : RUN firefox --version
 ---> Running in 75ab532d867a
Mozilla Firefox 57.0.2
Removing intermediate container 75ab532d867a
 ---> e62e99e54c63
Step 10/10 : RUN $(npm bin)/cypress run --record --key 3ba9ef5e-06d4-4f4f-a758-1fc5c2b570bb --browser firefox
 ---> Running in 0643aceb5f48
[09:48:09]  Verifying Cypress can run /root/.cache/Cypress/3.1.0/Cypress [started]
[09:48:10]  Verified Cypress!       /root/.cache/Cypress/3.1.0/Cypress [title changed]
[09:48:10]  Verified Cypress!       /root/.cache/Cypress/3.1.0/Cypress [completed]
Can't run because you've entered an invalid browser.

Browser: 'firefox' was not found on your system.

Available browsers found are: chrome, electron

UPD Without --key and --record I has same error.

Can't run in Chrome container

I am not sure how to run Cypress in the chrome container. The cypress binary doesn't seem to available in it.

$ docker run --rm cypress/browsers:chrome62 cypress run --browser chrome
docker: Error response from daemon: OCI runtime create failed: container_linux.go:295: starting container process caused "exec: \"cypress\": executable file not found in $PATH": unknown.

Running on jenkins results in permission denied creating directory

Environment

  • Jenkins 2.138.1
  • Amazon Linux AMI 2018.03.0

Jenkinsfile

pipeline {
  agent {
    // this image provides everything needed to run Cypress
    docker {
      image 'cypress/base:10'
    }
  }

  stages {
    // first stage installs node dependencies and Cypress binary
    stage('build') {
      environment {
        HOME = "."
      }
      steps {
        echo "Running build ${env.BUILD_ID} on ${env.JENKINS_URL}"
        timeout(time: 5, unit: 'MINUTES') {
          nodejs(nodeJSInstallationName: 'Node 10.4.1', configId: 'npm') {
            sh 'npm ci'
            sh 'npm run cy:verify'
          }
        }
      }
    }

    stage('start local server') {
      steps {
        // start local server in the background
        // we will shut it down in "post" command block
        timeout(time: 5, unit: 'MINUTES') {
          nodejs(nodeJSInstallationName: 'Node 10.4.1', configId: 'npm') {
            sh 'nohup npm start &'
          }
        }
      }
    }

    // this tage runs end-to-end tests, and each agent uses the workspace
    // from the previous stage
    stage('cypress parallel tests') {
      
      steps {
        echo "Running build ${env.BUILD_ID}"
        timeout(time: 5, unit: 'MINUTES') {
          nodejs(nodeJSInstallationName: 'Node 10.4.1', configId: 'npm') {
            sh "npm run cypress:headless"
          }
        }
      }
    }
  }

  post {
    // shutdown the server running in the background
    always {
      echo 'Stopping local server'
      timeout(time: 5, unit: 'MINUTES') {
        nodejs(nodeJSInstallationName: 'Node 10.4.1', configId: 'npm') {
          sh 'pkill -f http-server'
        }
      }
    }
  }
}

Build Logs

docker run -t -d -u 501:502 -w /var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2 -v /var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2:/var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2:rw,z -v /var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2@tmp:/var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** cypress/base:10 cat
$ docker top 08b586a0c00a18cd2ed0b44ec7bf19a14986d76bc279f29652d99c42a574712d -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (build)
[Pipeline] echo
Running build 19 on ....
[Pipeline] timeout
Timeout set to expire in 5 min 0 sec
[Pipeline] {
[Pipeline] nodejs
Unpacking https://nodejs.org/dist/v10.4.1/node-v10.4.1-linux-x64.tar.gz to /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_10.4.1 on Amazon Linux AMI 2018.03.0 (i-07de9049df879a9eb)
$ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_10.4.1/bin/npm install -g nsp
npm WARN deprecated [email protected]: The Node Security Platform service is shutting down 9/30 - https://blog.npmjs.org/post/175511531085/the-node-security-platform-service-is-shutting
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_10.4.1/bin/nsp -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_10.4.1/lib/node_modules/nsp/bin/nsp
+ [email protected]
added 115 packages from 50 contributors in 3.422s
copy managed file [npm] to file:/var/lib/jenkins/workspace/-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2@tmp/config3565889387532646403tmp
[Pipeline] {
[Pipeline] sh
[-www_feature_ci-integration-GWZMSYY6XHJA7QDBD4KWGXZCOVUKOBI35JMKYOQV76QXZTCYE6CA@2] Running shell script
+ npm ci
Unhandled rejection Error: EACCES: permission denied, mkdir '/.npm'
Unhandled rejection Error: EACCES: permission denied, mkdir '/.npm'

Error

Unhandled rejection Error: EACCES: permission denied, mkdir '/.npm'

My Suspicions

  1. Is this because we do not run Jenkins as root and instead run jenkins as it's own user?

Release minor cypress base versions

Updating the node version in the latest cypress:base:10 broke my test builds because they were looking for a very specific node version. I'd recommend that if you're going to update the docker image, you version it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.