slim icon indicating copy to clipboard operation
slim copied to clipboard

Xvfb issues after slim build

Open ChaikaBogdan opened this issue 5 years ago • 7 comments

Greetings, i am trying to slim https://github.com/cypress-io/cypress-docker-images/tree/master/included/4.0.2 Using command (MAC): ./docker-slim build cypress/included:4.0.2 --http-probe=false
(I am also tried to use --from-dockerfile solution) But i am getting this error on container run:

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: (EE) 
Fatal server error:
(EE) Could not create lock file in /tmp/.tX99-lock
Platform: linux (4.19.76-linuxkit)
Cypress Version: 4.0.2

Can you suggest how it can be fixed or debugged? 2.9GB->733mb is an impressive result, i am really interested in finding workaround here. The fat image and original image are 100% working.

ChaikaBogdan avatar Feb 25 '20 04:02 ChaikaBogdan

@ChaikaBogdan thanks for sharing your docker-slim command and the image info! It'll help with the repro!

This specific failure appears to come from the xvfb package ( https://github.com/cypress-io/xvfb ). It's possible that the minified images includes /tmp/.tX99-lock already and it's causing this failure. Let me try to repro it to see if it's the case. There might be other problems too. This appears to be an advanced multi-process/app setup and it definitely needs a review.

Do you know much about the tool design and its internals? Curious about the main components and how they are supposed to interact...

kcq avatar Feb 25 '20 18:02 kcq

@kcq Thanks for quick response! I not sure about internal work of Cypress...its almost 3gb of all-in test framework. I know it's coming with a lot of bundled stuff - test runners, reporters, browsers, which probably require some real frame buffer even for headless run. Also it bundled with Node12+ (but you can force use system one)

The fastest way to test image is:

mkdir dummy
cd dummy
npm init -y
npm install cypress --save-dev
npx cypress open //to generate dummy tests
docker run -it -v $PWD:/e2e -w /e2e cypress/included:4.0.2 --browser chrome

Container itself doesn't have any http access, you can run tests just from their repo or even copy them inside container:

FROM cypress/included:4.0.2
COPY cypress /e2e/cypress
COPY cypress.json /e2e
COPY package.json /e2e
WORKDIR /e2e

It's very handy in CI/CD, because you can just grab junit xml reports after run and pass them to Jenkins for example.

ChaikaBogdan avatar Feb 25 '20 19:02 ChaikaBogdan

@ChaikaBogdan Thanks for the extra info! This is super helpful! I'll try to repo and share my findings soon.

One thing to note is that you should probably pass the same extra parameters you have in your docker run command when you run docker-slim: ./docker-slim build --http-probe=false --mount $(pwd):/e2e --workdir /e2e --cmd '--browser chrome' cypress/included:4.0.2

kcq avatar Feb 25 '20 20:02 kcq

@kcq Thanks, error still same, but your arguments make more sense

ChaikaBogdan avatar Feb 26 '20 08:02 ChaikaBogdan

any update here? i am also gettting same issue.

kusumkappdirect avatar Mar 01 '21 07:03 kusumkappdirect

So, I made a little spike about possible slimming of cypress/included

Its looks like, what docker-slim is too aggressively removing everything related to Node and Cypres from the target image. I was able to get to some "almost working" state with:

./docker-slim build --http-probe=false --include-shell --include-path /usr/bin --include-path /usr/local --include-path /root/.cache/Cypress --include-path /usr/lib --target cypress/included:6.6.0

But cypress verify still results in an error...

  • docker run -it --entrypoint sh cypress/included.slim
  • Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

A similar issue was solved by https://github.com/iperdomo/cypress-docker-test#fixing-the-errors, but in my case I just getting different error

  • docker run -it --volume=/var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket --entrypoint sh cypress/included.slim
  • Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: Connection refused And no,-include-path /var/run/ doesnot help

Anyway, right now image weighs 1.62 GB unpacked...which is already more than just take node:buster-slim and install Cypress on top with Chrome. https://github.com/ChaikaBogdan/cypress_slim

Screenshot 2021-03-07 at 02 06 55

I wonder if it is related to the global install of Cypress in the original image...but no idea for now how to solve the socket issue

ChaikaBogdan avatar Mar 07 '21 00:03 ChaikaBogdan

I'm using docker-slim to build an original docker image which uses nodejs & xvfb-run, it also reports:

...
cmd=build info=continue.after mode='timeout&exec' message='provide the expected input to allow the container inspector to continue its execution' 
cmd=build prompt='waiting for the target container (30 seconds)'
cmd=build info=event message='done waiting for the target container' 
cmd=build info=continue.after mode='exec' shell='cd /renderserver && xvfb-run node index.js' 
docker-slim[build][exec]: output: xvfb-run: error: Xvfb failed to start
cmd=build info=continue.after mode='exec' exitcode='1'
...

The problem is: why can't i see the log output? In interactive mode there is.

chenzx avatar Nov 09 '21 06:11 chenzx