vendredi 14 décembre 2018

Runnig tests on docker from PhpStorm does not start apache2

I managed to configure PhpStrom with docker based on php7.1-apache image. docker-compose.yml is below:

version: '3'

services:

  www:
    image: php:7.1-apache
    volumes:
      - .:/var/www/html/
    ports:
      - "80:80"

And in my app I have unit tests and api tests. There is no problem with running unit tests from phpstorm. Remote interpreter is being used correctly.

The problem is with api tests that make http requests to web-server. I figured out that apache2 daemon is not started at all.

docker ps --no-trunc shows:

php /var/www/html/vendor/phpunit/phpunit/phpunit --no-configuration --filter '/(::should_do_something)( .*)?$/' ExampleTest /var/www/html/tests/ExampleTest.php --teamcity

And in container I can see:

$:~/workspace/phpstorm-docker$ docker-compose exec www bash
root@aa13971914b2:/var/www/html/tests# service apache2 status
[FAIL] apache2 is not running ... failed!

That's because PhpStrom does not start apache2-foreground process.

If I put sleep(15) before api test execution and inside container run:

service apache2 start 

Test is passing.

Do you know how to make PhpStorm to start also apache2 web server to have complete container?

Thanks.

Aucun commentaire:

Enregistrer un commentaire