thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 428 forks source link

Launching specs with docker-compose #1019

Closed RemyMaucourt closed 7 years ago

RemyMaucourt commented 7 years ago

I can't launch rspec with docker-compose since I installed capybara-webkit.

This next command just hold up for hours, doing nothing:

$ docker-compose run web xvfb-run -a bundle exec rspec

Running it with the --verbose option don't give much more information.

It's working if I launch a bash terminal in my container and fire the command from there. $ docker-compose run web bash then $ xvfb-run -a bundle exec rspec spec launch the specs correctly.

Is there a special config for docker-compose I should be aware of?

The Dockerfile:

FROM ruby:2.4.1

RUN apt-get update -qq && apt-get install -y \
  build-essential \
  libpq-dev \
  nodejs \
  xvfb \
  qt5-default \
  libqt5webkit5-dev \
  gstreamer1.0-plugins-base \
  gstreamer1.0-tools \
  gstreamer1.0-x

RUN mkdir /app_dir
WORKDIR /app_dir

ADD Gemfile* /app_dir/

RUN bundle install

COPY . .

I give more details on this Stackoverflow post

ryansch commented 7 years ago

I didn't have much luck with xvfb-run so I just put the following into my entrypoint:

    echo 'Starting Xvfb'
    Xvfb :99 -screen 0 1280x1024x24 &
    export DISPLAY=:99

(This only runs when we're running rspec or set an env var.)

jferris commented 7 years ago

Could you run something else within xvfb-run to figure out if it's something capybara-webkit is doing? For example: docker-compose run web xvfb-run -a bash

RemyMaucourt commented 7 years ago

Well, it seems to be a docker-compose / xvfb problem: docker-compose run web xvfb-run -a bash is staying on hold too.

jferris commented 7 years ago

I'm going to close this issue, as it doesn't seem like a bug in capybara-webkit, but feel free to continue commenting.

If you wrap the xvfb-run invocation in a shell, does that have any effect?

docker-compose run bash -c 'xvfb-run -a rspec'

I don't know what's causing the hang, but my best guesses are something to do with 1) the default shell 2) stdin 3) interactive vs non-interactive shell invocations.

RemyMaucourt commented 7 years ago

Thank you for the courtesy and the reactivity.

docker-compose run web bash -c 'xvfb-run -a rspec' stays on hold too.

I like the 'non-interactive shell' lead, I keep investigating and will keep you informed.

asafigan commented 7 years ago

I'm having the exact same problem. If you find a fix or any more information could you pass it on?

RemyMaucourt commented 7 years ago

I endend up writing another Stackoverflow post

jamescontent commented 5 years ago

I realize this is an old post, but in case anyone comes across it you should check out the work that Mark Adams did with this handy script. With this script (also take a look at how he uses it in the dockerfiles in that same repo), I'm at least able to run docker-compose run web xvfb-run rspec correctly and it functions as expected. I'm still, however, not able to get it to run when I set it as either a command in the Dockerfile or docker-compose.yml file.