Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Added docker tests to travis
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Apr 23, 2018
1 parent 32cec04 commit c7b4d02
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 28 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,18 @@ matrix:
env:
- DEPS=latest
- MONGO_DRIVER=mongodb
- PHP_VERSION=7.1
- DOCKER=true
- php: 7.2
env:
- DEPS=lowest
- MONGO_DRIVER=mongodb
- DOCKER=true
- php: 7.2
env:
- DEPS=locked
- MONGO_DRIVER=mongodb
- DOCKER=true
- php: 7.2
env:
- DEPS=latest
- MONGO_DRIVER=mongodb
- DOCKER=true

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
Expand All @@ -91,7 +86,7 @@ install:
script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $DOCKER == 'true' ]]; then docker exec -it $(docker ps -f name=zfapigilitydoctrine_php_1 | awk '{print $1;}' | tail -n 1) bash /docker/.travis.docker; fi
- docker-compose run --rm php

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi
Expand Down
21 changes: 11 additions & 10 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ From the root directory of this project run
docker-compose build
```

This will build the php container. Next run
This will build the php container.

```
docker-compose up
```

This will spin up the php container and a mongo container.

To connect to the php container and run the unit tests
run
To connect to the php container and run the unit tests run

```
docker-compose run php bash
docker-compose run --rm php bash
```

You will connect to the php container a the root directory.
Expand All @@ -36,7 +29,15 @@ You will connect to the php container a the root directory.
## Unit Tests

Having run `composer install` you may now run the unit tests
inside the container with

```
vendor/bin/phpunit
```

You may run the unit tests through the container without connecting
with bash via

```
docker-composer run --rm php
```
15 changes: 6 additions & 9 deletions docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ RUN apk add --no-cache \
autoconf \
make \
g++ \
bash
bash \
git \
openssl-dev

RUN pecl install mongodb && docker-php-ext-enable mongodb
RUN echo "memory_limit=2G" >> /usr/local/etc/php/php.ini
RUN if [ ${PHP_VERSION:0:3} == "5.6" ] ; then pecl install mongo && echo "extension=mongo.so" >> /usr/local/etc/php/php.ini ; else pecl install mongodb && docker-php-ext-enable mongodb ; fi
RUN set -o pipefail && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN echo -e '#!/bin/sh' > /usr/local/bin/entrypoint.sh \
RUN echo -e '#!/bin/sh ' > /usr/local/bin/entrypoint.sh \
&& echo -e 'while ! nc -z ${MONGO_HOST:-mongo} ${MONGO_PORT:-27017}; do sleep 1; done' >> /usr/local/bin/entrypoint.sh \
&& echo -e 'exec "$@"' >> /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /docker
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["./vendor/bin/phpunit"]

# RUN apt-get update
# RUN apt-get --yes install vim
# RUN apt-get --yes install git
# RUN apt-get --yes install inetutils-ping
# RUN apt-get --yes install host
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ services:
build:
context: .
args:
- PHP_VERSION=${PHP_VERSION:-7.2}
dockerfile: docker/Dockerfile
- PHP_VERSION=${TRAVIS_PHP_VERSION:-7.2}
dockerfile: Dockerfile
depends_on:
- mongo
volumes:
Expand Down
1 change: 0 additions & 1 deletion docker/connect

This file was deleted.

Empty file removed docker/data/.gitkeep
Empty file.

0 comments on commit c7b4d02

Please sign in to comment.