Docker-compose + PHPUnit kill my container after running the test

Answered

I've set up the cli-interpreter following the tutorial and a video and I got it working.

However, as I'm developing the site, I have docker-compose running in the background via this command "docker-compose up -d"

After running any test in PHPStorm my app container is stopped by PHPStorm.

Is there a way to keep it running?

 

Here is the print out in cli when running the test. You can see that the last step exits the container.

----------------------------------------------------------------------------------------------------------

Testing started at 4:00 PM ...
docker-compose://[/path_to_my_project/docker-compose.yml]:app/php /var/www/vendor/phpunit/phpunit/phpunit --configuration /var/www/phpunit.xml --filter "/(::testSomething)( .*)?$/" SampleTest /var/www/tests/unit/SampleTest.php --teamcity
Starting my_phpstorm_helpers_1 ...
Recreating my_app ...
Attaching to my_app
app_1 | PHPUnit 7.1.5 by Sebastian Bergmann and contributors.
app_1 |
app_1 |
app_1 |
app_1 | app_1 |
app_1 | app_1 |
app_1 | app_1 |
app_1 | app_1 |
app_1 |
app_1 | Time: 4.06 seconds, Memory: 18.00MB
app_1 |
app_1 | OK (1 test, 8 assertions)
my_app exited with code 0
Aborting on container exit...
Stopping my_app ...

Process finished with exit code 0

2 comments
Comment actions Permalink

Hello,

That's how Docker workflow is currently done - containers are recreated.

Please vote for https://youtrack.jetbrains.com/issue/PY-18901 and check the comments for possible workarounds.

3
Comment actions Permalink

My workaround:

In PhpStorm as CLI-Interpreter choose as Remote server “Docker” instead “docker-compose”. There choose as image name your existing PHP image. In this case starts PhpStorm new own docker container if you run your unit test process.

Tested with PhpStorm Version 2018.3

See also https://youtrack.jetbrains.com/issue/PY-18901#focus=streamItem-27-2913437-0-0



1

Please sign in to leave a comment.