Created
November 14, 2016 15:49
-
-
Save mackensen/c0b53d55667f8975d59fbb7ccaa2c2c3 to your computer and use it in GitHub Desktop.
Mocked up gitlab config for running selenium in a linked container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom docker image which exposes 8080 | |
image: lafayette/hoth:5.5 | |
services: | |
- selenium/standalone-chrome:latest | |
before_script: | |
# Use 0.0.0.0 instead of localhost to allow external connections | |
- php -S 0.0.0.0:8080 -t ../ &> /dev/null & | |
job1: | |
script: | |
# Detect the IP and tell behat about it | |
- export BEHAT_IP=`ip addr show eth0 | grep -Po 'inet \K[\d.]+'` | |
- sed -i -e "s/localhost/$BEHAT_IP/" behat.yml | |
- vendor/bin/behat --format progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
autoload: | |
- %paths.base%/features/bootstrap | |
suites: | |
default: | |
contexts: | |
- YourContextHere | |
extensions: | |
Behat\MinkExtension: | |
base_url: 'http://localhost:8080' | |
browser_name: 'chrome' | |
sessions: | |
default: | |
selenium2: | |
wd_host: 'http://selenium__standalone-chrome:4444/wd/hub' |
Another thank you! This was VERY tricky to figure out! GitLab's magic networking is definitely making things more difficult here. Two additional things I needed to get this working:
- Instead of
ip addr show eth0 | grep -Po 'inet \K[\d.]+'
I usedhostname -I | awk '{print $1}'
becauseiproute2
is not installed on default PHP images. - I also had proxy servers in my environment. I had to add the IP address to the NO_PROXY variable.
Resulting in the following additions to the script section:
- export LOCAL_IP_ADDRESS=`hostname -I | awk '{print $1}'`
- export NO_PROXY=localhost,$LOCAL_IP_ADDRESS
- sed -i -e "s/localhost/$LOCAL_IP_ADDRESS/" behat.yml
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! Tired to wait when they will create normal docker network for CI containers and services...