I am using a docker image for functional tests of my project. This image is based on alpine and have the nginx and the php-fpm services running by the supervisord, and my functional test do rest calls to this docker instance.
Basically the .travis.yml:
- Build the image
- Start the container
- Call the PHPUnit to test;
The image is created fine and the container is UP. I added some debug info to verify this:
>> docker run -d --rm --name resttemplate-test-instance -v /home/travis/build/byjg/php-rest-template:/srv/web -p "127.0.0.1:80:80" resttemplate-test
f3986de1c86629123896a0aa7f6ec407f617f261383c3b6a358e9dfcd3d06d77
Exit status : 0
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f3986de1c866 resttemplate-test "docker-php-entryp..." Less than a second ago Up Less than a second 443/tcp, 127.0.0.1:80->80/tcp, 9000/tcp resttemplate-test-instance
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' resttemplate-test-instance
172.17.0.2
But when the PHPUnit run I got the followed message for every single test:
cURL error 56: Recv failure: Connection reset by peer (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
If I repeat line by line all the steps existing in the .travis.yml in my local environment everything works fine. This error occurs only in travis.
Here is the link for the build is failing: https://travis-ci.org/byjg/php-rest-template/jobs/305476720#L728
Here have my .travis.yml:
sudo: required
language: php
php:
- "7.1"
- "7.0"
- "5.6"
env:
- APPLICATION_ENV=test
services:
- docker
install:
- composer install
- composer restdocs
- composer migrate -- reset --yes
- composer build
- docker ps -a
- docker inspect resttemplate-test-instance
- docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' resttemplate-test-instance
- sudo chown 82:82 src/sample.db
- sudo chown 82:82 src/
script:
- phpunit