Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Problems with webkit_server through Docker #912

Closed
davidpdrsn opened this issue May 5, 2016 · 5 comments
Closed

Problems with webkit_server through Docker #912

davidpdrsn opened this issue May 5, 2016 · 5 comments

Comments

@davidpdrsn
Copy link

I'm seeing the following error for tests that have :js

  1) creating move edits the move
     Failure/Error: visit new_move_path(as: user)
     Capybara::Webkit::ConnectionError:
       /box/gems/capybara-webkit-1.8.0/bin/webkit_server failed to start.
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/connection.rb:87:in `parse_port'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/connection.rb:93:in `discover_port'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/connection.rb:74:in `start_server'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/connection.rb:31:in `initialize'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/driver.rb:14:in `new'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit/driver.rb:14:in `initialize'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit.rb:15:in `new'
     # /box/gems/capybara-webkit-1.8.0/lib/capybara/webkit.rb:15:in `block in <top (required)>'
     # /box/gems/capybara-2.6.2/lib/capybara/session.rb:84:in `driver'
     # /box/gems/capybara-2.6.2/lib/capybara/session.rb:70:in `initialize'
     # /box/gems/capybara-2.6.2/lib/capybara.rb:276:in `new'
     # /box/gems/capybara-2.6.2/lib/capybara.rb:276:in `current_session'
     # /box/gems/capybara-2.6.2/lib/capybara/dsl.rb:46:in `page'
     # /box/gems/capybara-2.6.2/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
     # ./spec/features/credits/moves_spec.rb:24:in `block (2 levels) in <top (required)>'
     # ./spec/support/headless.rb:4:in `block (3 levels) in <top (required)>'
     # /box/gems/headless-2.2.3/lib/headless.rb:134:in `run'
     # ./spec/support/headless.rb:3:in `block (2 levels) in <top (required)>'
     # /box/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
     # /box/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `block in load'
     # /box/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
     # /box/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
     # /box/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
     # -e:1:in `<main>'

The command I run is docker-compose run web bin/rspec spec/features.

Dockerfile:

FROM ruby:2.3.0

RUN apt-get update -qq && apt-get install -y build-essential

# for postgres
RUN apt-get install -y libpq-dev

# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev

# for capybara-webkit
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb

# for a JS runtime
RUN apt-get install -y nodejs

RUN mkdir /app
WORKDIR /app
ENV BUNDLE_PATH /box
COPY . /app/

docker-compose.yml:

db:
  image: postgres:9.4
  ports:
    - "5432"
web:
  build: .
  command: bin/rails s -b 0.0.0.0 -p 3000
  volumes:
    - .:/app
  volumes_from:
    - box
  stdin_open: true
  ports:
    - "3000:3000"
  links:
    - db
box:
  image: busybox
  volumes:
    - /box

If I jump into the container with docker-compose run web bash and run web_server manually I see this

root@3f00491727e9:/app# /box/gems/capybara-webkit-1.8.0/bin/webkit_server
/box/gems/capybara-webkit-1.8.0/bin/webkit_server: error while loading shared libraries: libQt5WebKitWidgets.so.5: cannot open shared object file: No such file or directory

I have tried using headless as described here but that didn't work.

Any idea what I'm doing wrong?

@davidpdrsn
Copy link
Author

I have now read through the installation instructions in the wiki but it didn't help. My Dockerfile now looks like

FROM ruby:2.3.0

RUN apt-get update -qq && apt-get install -y build-essential

# for postgres
RUN apt-get install -y libpq-dev

# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev

# for capybara-webkit
RUN apt-get install -y libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x xvfb libqt4-webkit libqt4-dev

# for a JS runtime
RUN apt-get install -y nodejs

RUN mkdir /app
WORKDIR /app
ENV BUNDLE_PATH /box
COPY . /app/

@jferris
Copy link
Contributor

jferris commented May 9, 2016

Is it possible that you're providing vendored/compiled gems from the host system or a different Docker container? If the necessary libraries aren't present, capybara-webkit can't compile, so it looks like it was compiled when the libraries were available but then run in an environment where they weren't. How are you running bundle install in the Docker environment?

@davidpdrsn
Copy link
Author

Yes I am installing gems into another container that runs busybox. This is to cache gems and make bundle install faster. So sounds like that might be the issue.

Any ideas how I would fix that?

@jferris
Copy link
Contributor

jferris commented May 9, 2016

I haven't worked with that particular Docker workflow, but you'll need to compile capybara-webkit on a host that has the linked libraries at the same locations as the host you're going to run the tests on.

This doesn't look like a bug in capybara-webkit, so I'm going to close this issue. Feel free to continue commenting if you have further questions or ideas.

@igorvpcleao
Copy link

igorvpcleao commented May 24, 2016

I've spent lots of time trying to solve this issue.
Here's what I've found:

  1. Instead of running rspec you should run xvfb-run -a rspec

It seems capybara needs a X Server, so that's for it. Make sure you have xvfb installed.

In case your docker base image is CentOs, you may need run one more step.

  1. dbus-uuidgen > /var/lib/dbus/machine-id

You can do this either adding a RUN at your Dockerfile or running it before a test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants