GithubHelp home page GithubHelp logo

zyuzka / docker-chromedriver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spryker/docker-chromedriver

0.0 1.0 0.0 24 KB

Chromedriver with Chromium Docker image / PHP Installer

Home Page: https://spryker.com/

License: MIT License

Dockerfile 13.97% Shell 63.59% PHP 22.44%

docker-chromedriver's Introduction

Chromedriver Chromium

This is a Dockerfile to create a Webdriver image with ChromeDriver and Chromium out-of-box.

Usage

General

The spryker/chromedriver image is public and available on Docker Hub. You can use this repository to run and install Chromedriver with appropriate version of Chromium within:

Docker

The spryker/chromedriver is available on Docker Hub. starts a Chromedriver server on port 4444 by default. In its turn, Chromedriver wraps Webdriver to run tests within Chromium ecosystem.

The very basic docker-compose configuration that is sufficient to use Chromium and Chromedriver within your ecosystem is next:

version: "3.7"
services:
  chromedriver:
    image: spryker/chromedriver
    init: true
    environment:
      - CHROMIUM_VERSION=726767
    volumes:
      - ./assets:/home/webdriver/assets:ro
    expose:
      - "4444"

You can control the revision of Chromium (and Chromedriver as well) with just putting CHROMIUM_REVISION environment variable into docker-compose template (as mentioned above).

Composer

To install Chromedriver with Chromium onboard, you just need to run

composer require --dev "spryker/docker-chromedriver"

and modify composer.json file to make all necessary installation actions:

{
  "scripts": {
    "post-install-cmd": [
      "ChromedriverInstaller\\Installer::installChromedriver"
    ],
    "post-update-cmd": [
      "ChromedriverInstaller\\Installer::installChromedriver"
    ]
  }
}

This will lead to install of the latest nightly build of Chromedriver and Chromium.

To freeze version of Chromedriver you can take on any revision number and mention it within composer.json configuration (just ensure your revision contains both Chromedriver and Chromium archives):

{
  "config": {
    "chromium-revision": 814168
  }
}

Next time you will run Composer install/update, script will check whether the revision has changed and/or differs from latest/fixed one. If so, it will install the actual version of Chromedriver. Nothing will happen in else case. This is to reduce Composer worktime.

Skip installation

To ignore Chromedriver installation process just set the appropriate variable berfore running Composer:

export COMPOSER_IGNORE_CHROMEDRIVER=1

This will force skipping installation procedure during Composer run.

Travis CI

To use this package within Travis image you just need to use chromium-installer to prepare Chromium and Chromedriver for run.

First of all, you need to specify cache directory:

cache:
  directories:
    - $HOME/chromium-ecosystem

Then download and unzip installer:

before_install:
  # Chromedriver section
  - curl -L "https://github.com/spryker/docker-chromedriver/archive/master.zip" -o $HOME/chromium-ecosystem/chromiumdriver.zip
  - unzip -o $HOME/chromium-ecosystem/chromiumdriver.zip -d $HOME/chromium-ecosystem/
  # Here you can leave 0 for installing latest nightly build
  - export CHROMEDRIVER_REVISION=814168

And finally run installer:

  # Exposes ${CHROMEDRIVER_BINARY} and ${CHROMIUM_BINARY}
  - . $HOME/chromium-ecosystem/chromiumdriver-master/chromium-installer $CHROMEDRIVER_REVISION $HOME/chromium-ecosystem false

And finally, ensure you have added all dependencies, needed to run Chromium:

addons:
  apt:
    update: true
    packages:
      - unzip
      - gnupg
      - libnss3-dev
      - ca-certificates
      - fonts-liberation
      - libappindicator3-1
      - libasound2
      - libatk-bridge2.0-0
      - libatk1.0-0
      - libc6
      - libcairo2
      - libcups2
      - libdbus-1-3
      - libexpat1
      - libfontconfig1
      - libgbm1
      - libgcc1
      - libglib2.0-0
      - libgtk-3-0
      - libnspr4
      - libnss3
      - libpango-1.0-0
      - libpangocairo-1.0-0
      - libstdc++6
      - libx11-6
      - libx11-xcb1
      - libxcb1
      - libxcomposite1
      - libxcursor1
      - libxdamage1
      - libxext6
      - libxfixes3
      - libxi6
      - libxrandr2
      - libxrender1
      - libxss1
      - libxtst6
      - lsb-release
      - wget
      - xdg-utils

That's it! Now you can just run Chromedriver and pass right Chromium executable into Webdriver config:

script:
- bash -c "${CHROMEDRIVER_BINARY} --port=4444 --whitelisted-ips= --url-base=/wd/hub --log-path=/tmp/chromedriver.log --log-level=DEBUG" > /dev/null &

Dependencies

To run Chromedriver with Chromium you need to install this list of dependencies beforehand:

apt-get update \
&& apt-get install gnupg \
      libnss3-dev \
      ca-certificates \
      fonts-liberation \
      libappindicator3-1 \
      libasound2 \
      libatk-bridge2.0-0 \
      libatk1.0-0 \
      libc6 \
      libcairo2 \
      libcups2 \
      libdbus-1-3 \
      libexpat1 \
      libfontconfig1 \
      libgbm1 \
      libgcc1 \
      libglib2.0-0 \
      libgtk-3-0 \
      libnspr4 \
      libnss3 \
      libpango-1.0-0 \
      libpangocairo-1.0-0 \
      libstdc++6 \
      libx11-6 \
      libx11-xcb1 \
      libxcb1 \
      libxcomposite1 \
      libxcursor1 \
      libxdamage1 \
      libxext6 \
      libxfixes3 \
      libxi6 \
      libxrandr2 \
      libxrender1 \
      libxss1 \
      libxtst6 \
      lsb-release \
      wget \
      xdg-utils

Software

The following software is included in this image:

Pay attention

Since this package relies on nightly builds, not all versions of Chromium are available to download. To check the available revisions, please visit Google Chromium Snapshots archive and find appropriate snapshot revision.

docker-chromedriver's People

Contributors

bezpiatovs avatar zyuzka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.