title: Docker: How to use selenium server to do nightwatchJS test?
body: <p>I don't know how to run a selenium server with my NodeJS application, whose files are located in the <code>./bundle</code> folder of the custom <code>e2e:latest</code> docker image.</p>
  
  <p>I think I have to add the selenium server and webdriver chrome into the Dockerfile for the <code>e2e:latest</code> image, don't I?</p>
  
  <p>This is what I have done so far:</p>
  
  <p>I've created a java:8-jre based docker image with NodeJS and nightwatchJS:</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM java:8-jre
  
  ## Node.js setup
  RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
  RUN apt-get install -y nodejs
  
  ## Nightwatch
  RUN npm install -g nightwatch
  </code></pre>
  
  <p>This image is then used for the test:</p>
  
  <p><strong>gitlab-ci.yml</strong></p>
  
  <pre><code>build:
    stage: build
    tags:
      - deploy
    script:
      - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
      - meteor npm install --production
      - meteor build $PACKAGE_PATH --directory
      # Maybe something like...? - docker build -t $CI_REGISTRY_IMAGE:e2e .
  
  nightwatch:
    image: e2e:latest
    stage: e2e
    tags:
      - e2e
    before_script:
      - cd ./bundle
    script:
      - nightwatch
  </code></pre>
  
  <p>The configuration looks like this:</p>
  
  <p><strong>nightwatch.conf.js</strong></p>
  
  <pre><code>module.exports = {
      'src_folders'           : ['test/e2e'],
      'output_folder'         : 'reports',
      'custom_commands_path'  : '',
      'custom_assertions_path': '',
      'page_objects_path'     : '',
      'globals_path'          : '',
      'test_runner'           : {
          'type'   : 'mocha',
          'options': {
              'ui'      : 'bdd',
              'reporter': 'list'
          }
      },
  
      'selenium': {
          'start_process': false,
          'server_path'  : '',
          'log_path'     : '',
          'host'         : '127.0.0.1',
          'port'         : 4444,
          'cli_args'     : {
              'webdriver.chrome.driver': './bin/chromedriver'
          }
      },
  
      'test_settings': {
          'default': {
              'launch_url'   : 'http://localhost',
              'selenium_port': 4444,
              'selenium_host': 'localhost',
              'silent'       : true,
              'screenshots'  : {
                  'enabled': true,
                  'path'   : 'reports/error-screenshots'
              },
              'desiredCapabilities': {
                  'browserName'      : 'chrome',
                  'javascriptEnabled': true,
                  'acceptSslCerts'   : true
              }
          },
  
          'chrome': {
              'desiredCapabilities': {
                  'browserName'      : 'chrome',
                  'javascriptEnabled': true,
                  'acceptSslCerts'   : true
              }
          }
      }
  }
  </code></pre>