Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Chrome Driver - Docker image #121

Closed
Guikingone opened this issue Oct 9, 2018 · 12 comments
Closed

[QUESTION] Chrome Driver - Docker image #121

Guikingone opened this issue Oct 9, 2018 · 12 comments

Comments

@Guikingone
Copy link

Hi everyone,

Small question about the usage of Panther into a PHP Alpine image, I've tried to install Chromedriver and chromium but here's the error that I get:

#!/usr/bin/env php
PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

Error:         No code coverage driver is available

Testing E2E
E                                                                   1 / 1 (100%)

Time: 8.08 seconds, Memory: 40.25MB

There was 1 error:

1) E2E\Core\HomeE2ETest::testStatusCode
RuntimeException: sh: exec: line 1: /var/www/marketReminder/vendor/symfony/panther/src/ProcessManager/../../chromedriver-bin/chromedriver_linux64: not found


/var/www/marketReminder/vendor/symfony/panther/src/ProcessManager/WebServerReadinessProbeTrait.php:50
/var/www/marketReminder/vendor/symfony/panther/src/ProcessManager/ChromeManager.php:49
/var/www/marketReminder/vendor/symfony/panther/src/Client.php:80
/var/www/marketReminder/vendor/symfony/panther/src/Client.php:272
/var/www/marketReminder/vendor/symfony/panther/src/Client.php:186
/var/www/marketReminder/E2E/Core/HomeE2ETest.php:26

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Remaining deprecation notices (1)

  1x: Doctrine\Common\ClassLoader is deprecated.
    1x in HomeE2ETest::testStatusCode from E2E\Core

make: *** [panther] Error 2

For information, here's the Dockerfile:

# Development build
FROM php:fpm-alpine as base

ARG WORKFOLDER

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PANTHER_NO_SANDBOX 1
ENV PANTHER_WEB_SERVER_PORT 9800
ENV WORKPATH ${WORKFOLDER}

RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev postgresql-dev gnupg graphviz make autoconf git zlib-dev curl chromium chromium-chromedriver go rabbitmq-c rabbitmq-c-dev \
    && docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install zip intl pdo_pgsql pdo_mysql opcache json pdo_pgsql pgsql mysqli \
    && pecl install apcu redis grpc protobuf amqp \
    && docker-php-ext-enable apcu mysqli redis grpc protobuf amqp

COPY docker/php/conf/php.ini /usr/local/etc/php/php.ini

# Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Blackfire (Docker approach) & Blackfire Player
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
    && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/amd64/$version \
    && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
    && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
    && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
    && mkdir -p /tmp/blackfire \
    && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \
    && mv /tmp/blackfire/blackfire /usr/bin/blackfire \
    && rm -Rf /tmp/blackfire \
    && curl -OLsS http://get.blackfire.io/blackfire-player.phar \
    && chmod +x blackfire-player.phar \
    && mv blackfire-player.phar /usr/local/bin/blackfire-player

# PHP-CS-FIXER & Deptrac
RUN wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer \
    && chmod a+x php-cs-fixer \
    && mv php-cs-fixer /usr/local/bin/php-cs-fixer \
    && curl -LS http://get.sensiolabs.de/deptrac.phar -o deptrac.phar \
    && chmod +x deptrac.phar \
    && mv deptrac.phar /usr/local/bin/deptrac

RUN mkdir -p ${WORKPATH} \
    && chown -R www-data /tmp/ \
    && mkdir -p \
       ${WORKPATH}/var/cache \
       ${WORKPATH}/var/logs \
       ${WORKPATH}/var/sessions \
    && chown -R www-data ${WORKPATH}/var

WORKDIR ${WORKPATH}

COPY --chown=www-data:www-data . ./

# Production build
FROM base as production

COPY --from=gcr.io/marketreminder-206206/node:latest ${WORKPATH}/public/build ./public/build

COPY docker/php/conf/production/php.ini /usr/local/etc/php/php.ini

RUN rm -rf /usr/local/bin/deptrac \
    && rm -rf /usr/local/bin/php-cs-fixer

I don't really see where the problem is coming from and i've search to see if someone has the same problem but nothing about this type of error, does anyone has an idea ?

PS: I've tried the installation recommanded by the documentation but the driver doesn't seem to be found

Thanks for the help :)

@dunglas
Copy link
Member

dunglas commented Oct 9, 2018

You need to install the unzip command in the container. See #54.

@Guikingone
Copy link
Author

@dunglas Thanks for the help, does the docker-php-ext-install zip command doesn't install it already?

@dunglas
Copy link
Member

dunglas commented Oct 9, 2018

No, it installs the extension providing the ZipArchive class, but not the unzip binary.

@Guikingone
Copy link
Author

And ... stupid question but how can I install it using the php-fpm alpine image?

Here's my new line related to the apk add:

RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libzip-dev zip icu-dev postgresql-dev gnupg graphviz make autoconf git unzip zlib-dev curl chromium chromium-chromedriver go rabbitmq-c rabbitmq-c-dev \
    && docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
    && docker-php-ext-configure zip --with-libzip \
    && docker-php-ext-install zip intl pdo_pgsql pdo_mysql opcache json pdo_pgsql pgsql mysqli \
    && pecl install apcu redis grpc protobuf amqp \
    && docker-php-ext-enable apcu mysqli redis grpc protobuf amqp

Can seem stupid but I don't find a correct way to install it ... 🤔

@dunglas
Copy link
Member

dunglas commented Oct 11, 2018

I'm not sure if it's possible to use Chromedriver on Alpine. I'll give a try asap.

@alexsegura
Copy link
Contributor

@Guikingone hello, did you finally managed to make it work?
I'm also trying to make it work on Alpine Linux.

@alexsegura
Copy link
Contributor

@Guikingone for Alpine Linux, the simplest solution is to use alternative binary

RUN apk add --no-cache \
        chromium \
        chromium-chromedriver
ENV PANTHER_CHROME_DRIVER_BINARY /usr/lib/chromium/chromedriver

@Guikingone
Copy link
Author

@alexsegura I've not found a viable solution, yours work (except that now, Chrome crash):

1) App\Tests\UI\Action\Security\RegistrationActionSystemTest::testResponseSuccess with data set #0 ('/fr/enregistrement', 'Créer un compte')
Facebook\WebDriver\Exception\UnknownServerException: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.38 (f91d32489882be7df38da3422a19713bfd113fa5),platform=Linux 4.9.125-linuxkit x86_64)

/var/www/cyclepath/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:114
/var/www/cyclepath/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:326
/var/www/cyclepath/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126
/var/www/cyclepath/vendor/symfony/panther/src/ProcessManager/ChromeManager.php:59
/var/www/cyclepath/vendor/symfony/panther/src/Client.php:80
/var/www/cyclepath/vendor/symfony/panther/src/Client.php:272
/var/www/cyclepath/vendor/symfony/panther/src/Client.php:186
/var/www/cyclepath/tests/UI/Action/Security/RegistrationActionSystemTest.php:51

Maybe the IP and port which stop it?

@Guikingone
Copy link
Author

Ok, seems to work (thanks to the PANTHER_NO_SANDBOX env variable), @dunglas maybe it could be a good idea to give the @alexsegura solution a small place in the README?

@dunglas
Copy link
Member

dunglas commented Nov 2, 2018

I agree! Is one of you interested in opening a PR?

@alexsegura
Copy link
Contributor

Here it is 🙂 #131

@chalasr chalasr closed this as completed Mar 2, 2019
@rodrigobb
Copy link

rodrigobb commented Apr 15, 2019

I also neede to add PANTHER_WEB_SERVER_PORT to make it work (in an Alpine 3.9 used in docker-compose).

ENV PANTHER_NO_SANDBOX 1
ENV PANTHER_WEB_SERVER_PORT 9800

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

No branches or pull requests

5 participants