Git Product home page Git Product logo

Comments (8)

bsimpson53 avatar bsimpson53 commented on July 30, 2024 2

In case this helps someone else...

I'm using the jenkins declarative pipeline syntax in a Jenkinsfile, jenkins runs containers by default as the jenkins user on the host but I've found (unexpectedly) that you can override that (feel free not to use root ;) ) with:

    stage('Cypress') {
      agent {
        dockerfile {
          dir 'test/cypress'
          args '-u 0:0'
        }
      }
      steps {
        sh 'PROJECT=$(pwd) && cd /opt/cypress && $(npm bin)/cypress run --project ${PROJECT}/test/cypress'
      }
    }

With test/cypress/Dockerfile:

FROM cypress/base:8

WORKDIR /opt/cypress

RUN echo '{}' > package.json && \
    npm install cypress

Thanks @Flambe and @bahmutov for documenting!

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

We have recently made cypress/base:8 the default image in #34 (which upgrades Node to 8), so you should switch to building from cypress/base:6 image. Then it works

FROM cypress/base:6

RUN npm install -g cypress
RUN cypress version
RUN cypress verify
$ docker build .
Sending build context to Docker daemon  36.86kB
Step 1/4 : FROM cypress/base:6
 ---> 79e6b8ee7ca4
Step 2/4 : RUN npm install -g cypress
 ---> Using cache
 ---> 47f787811594
Step 3/4 : RUN cypress version
 ---> Running in 59a161dd1c0b
Cypress package version: 2.1.0
Cypress binary version: 2.1.0
Removing intermediate container 59a161dd1c0b
 ---> 35653303a9db
Step 4/4 : RUN cypress verify
 ---> Running in 204d86b7f280
It looks like this is your first time using Cypress: 2.1.0

[14:34:05]  Verifying Cypress can run /usr/local/lib/node_modules/cypress/dist/Cypress [started]
[14:34:06]  Verified Cypress!       /usr/local/lib/node_modules/cypress/dist/Cypress [title changed]
[14:34:06]  Verified Cypress!       /usr/local/lib/node_modules/cypress/dist/Cypress [completed]
Removing intermediate container 204d86b7f280
 ---> 944e171ba654
Successfully built 944e171ba654

from cypress-docker-images.

Flambe avatar Flambe commented on July 30, 2024

That's worked, thank you!

Do you happen to know why node 8 breaks it?

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

the combination of the default user and npm install permissions I think, but the use case for installing Cypress globally is pretty slim right now, so we recommend installing it locally just like a regular dependency. Plus once we do a better job caching the downloaded binary (cypress-io/cypress#1300) then it would not be very painful even locally.

from cypress-docker-images.

Flambe avatar Flambe commented on July 30, 2024

Ah right.

The biggest problem with caching locally (for us) is that our current CI setup runs in disposable dockers each time. This'd mean that we're still installing from scratch each time.

If you do end up pre-caching in the base images, that'd be good (for us).

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

yeah, it is a problem. So on CircleCI and on Travis you can cache installed dependencies, even for Docker builds, other CIs should allow the same. For example cypress-example-recipes shows how to do this

And if you are hardcore Docker user, you could make a Docker images using your dependencies as a first step of the build using something like this https://github.com/bahmutov/double-docker

from cypress-docker-images.

Flambe avatar Flambe commented on July 30, 2024

We're using jenkins, but yeah, there should be something out there that I can find.

Thank you for all the info and help! I'll keep looking into it.

from cypress-docker-images.

bsimpson53 avatar bsimpson53 commented on July 30, 2024

Got exactly the same problem (cypress + docker + jenkins)

from cypress-docker-images.

Related Issues (20)

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.