thoughtbot/capybara-webkit

Launching specs with docker-compose

RemyMaucourt opened this issue · 8 comments

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

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.)

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

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

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.

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.

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

I endend up writing another Stackoverflow post

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.