question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build Cypress docker image for simple CI

See original GitHub issue

Most CI allow using custom Docker image as base. It would be really cool to have official public Cypress docker image. We have built one, here is our docker file

FROM node:6
RUN apt-get update
RUN apt-get install libgtk2.0-0 libnotify4 libgconf2-4 libnss3 xvfb --yes
RUN npm set progress=false
RUN npm i -g cypress-cli
ARG CYPRESS_VERSION
ENV CYPRESS_VERSION ${CYPRESS_VERSION:-0.16.2}
RUN echo Cypress version to install $CYPRESS_VERSION
RUN cypress install
RUN cypress verify

One could use specific cypress-cli version inside if needed.

To build and tag the image, we use this script

set e+x

# build image with everything needed to run Cypress
VERSION=0.16.2
LOCAL_NAME=front-end/cypress-ci
docker build --build-arg CYPRESS_VERSION=${VERSION} -t $LOCAL_NAME .

# tag and push the build to the registry
# https://docs.docker.com/mac/step_six/
IMAGE_ID=$(docker images -q $LOCAL_NAME)
NAME=<docker hub>/$LOCAL_NAME:$VERSION
docker tag $IMAGE_ID $NAME
docker push $NAME

We are pushing to internal Docker hub, but public is obviously the goal here. Then a Gitlab CI runner just uses that image as the base

image: <docker hub>/front-end/cypress-ci:0.16.2
# caching node_modules folder
# https://about.gitlab.com/2016/03/01/gitlab-runner-with-docker/
cache:
  paths:
  - node_modules/
before_script:
  - cypress verify
stages:
  - test
e2e_test:
  stage: test
  script:
    - npm install
    - npm test
    - npm run build
    - cypress ci

We have spec file bundle build step, otherwise we could just do

e2e_test:
  stage: test
  script:
    - cypress ci

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jheijkoopcommented, Oct 4, 2016

I modified your Dockerfile to run in jenkins CI

FROM node:6

RUN adduser --disabled-password --uid 1000 --shell /bin/bash ubuntu

RUN apt-get update --yes &&  apt-get install -y --force-yes \
  sudo \
  libgtk2.0-0 \
  libnotify4 \
  libgconf2-4 \
  libnss3 \
  xvfb \
  libasound2 \
  libxss1

RUN npm set progress=false
RUN npm i -g cypress-cli

ARG CYPRESS_VERSION
ENV CYPRESS_VERSION ${CYPRESS_VERSION:-0.16.5}
WORKDIR /home/ubuntu
RUN sudo -u ubuntu cypress install --cypress-version=$CYPRESS_VERSION
RUN sudo -u ubuntu cypress verify

# Clean up APT when done.
RUN SUDO_FORCE_REMOVE=yes apt-get remove -y sudo
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

I added a ubuntu user, because jenkins running under the ubuntu user jumps into the container with ids 1000:1000, which resulted in it not finding the cypress executable or not having write access for the .config it tries to create in / and I think I needed the extra libraries libasound2 libxss1

2reactions
jayfreshcommented, May 5, 2017

@RandallKent it would still be good to be able to run locally under Docker (we’re on a mixed Windows and Mac environment), and plug VNC into that. But exciting to hear there’s a cloud offering

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker | Cypress Documentation
This repo holds various Docker images for running Cypress locally and in CI. There are Docker images: cypress/base:<Node version> has the operating system ......
Read more >
Docker full circle: Continuous Integration (CI) with Cypress
Everyone is using your custom Docker image to manage dependencies and ... In this article, we'll look at building a continuous integration ......
Read more >
Building custom Docker images from cypress/included [shorts]
In this article, we will explore how we can build a Docker image and push them to an image registry such as DockerHub....
Read more >
Setup CI/CD Pipeline with GitHub Actions and Docker Image ...
Below is a simple test case where we searched some data and verified it. ... Below we add the container using a Cypress...
Read more >
Dockerize your Cypress tests | Johnny Metz
The cypress/included docker image's entrypoint is cypress run so we need to overwrite that with cypress open . We also need to append...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found