Skip to content

Commit

Permalink
[Docker] Add HHVM container (egeloen#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs authored Feb 8, 2017
1 parent 4a2dbe8 commit 5896f97
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 42 deletions.
7 changes: 7 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# IDE
IDE_SERVER_NAME=ivory-google-map-bundle

# Permissions
GROUP_ID=1000
USER_ID=1000

# Symfony deprecations
SYMFONY_DEPRECATIONS_HELPER=strict

# XDebug
XDEBUG=0
XDEBUG_HOST=192.168.0.1
XDEBUG_PORT=9000
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/docker export-ignore
/travis export-ignore
/Tests export-ignore
.env.dist export-ignore
.gitattributes export-ignore
Expand Down
28 changes: 7 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,19 @@ branches:
env:
global:
- COMPOSER_PREFER_LOWEST=false
- DOCKER_BUILD=false
- SYMFONY_DEPRECATIONS_HELPER=weak
- SYMFONY_VERSION=2.3.*

before_script:
- export DISPLAY=:99
- /sbin/start-stop-daemon -Sbmq -p /tmp/xvfb_99.pid -x /usr/bin/Xvfb -- ${DISPLAY} -ac -screen 0, 1600x1200x24
- curl http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.0.jar > selenium.jar
- curl http://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip > chromedriver.zip
- unzip chromedriver.zip
- java -jar selenium.jar -Dwebdriver.chrome.driver=./chromedriver > /dev/null 2>&1 &
- composer self-update
- composer require --no-update symfony/framework-bundle:${SYMFONY_VERSION}
- composer require --no-update --dev symfony/form:${SYMFONY_VERSION}
- composer require --no-update --dev symfony/templating:${SYMFONY_VERSION}
- composer require --no-update --dev symfony/yaml:${SYMFONY_VERSION}
- composer remove --no-update --dev friendsofphp/php-cs-fixer
- if [[ "$SYMFONY_VERSION" = *dev* ]]; then sed -i "s/\"MIT\"/\"MIT\",\"minimum-stability\":\"dev\"/g" composer.json; fi
- composer update --prefer-source `if [[ $COMPOSER_PREFER_LOWEST = true ]]; then echo "--prefer-lowest --prefer-stable"; fi`

script: vendor/bin/phpunit --configuration phpunit.travis.xml --coverage-clover build/clover.xml

after_success:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/clover.xml
install: travis/install.sh
script: travis/script.sh
after_success: travis/success.sh

matrix:
include:
- php: 5.6
services: [docker]
env: DOCKER_BUILD=true
- php: 5.6
env: SYMFONY_VERSION=2.3.* COMPOSER_PREFER_LOWEST=true
- php: 5.6
Expand Down
6 changes: 6 additions & 0 deletions Resources/doc/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ To run the test suite, you can use:
$ docker-compose run --rm php vendor/bin/phpunit
```

If you want to run the test suite against [HHVM](http://hhvm.com/), you can use:

``` bash
$ docker-compose run --rm hhvm vendor/bin/phpunit
```

Some tests requires a [Selenium Server](http://www.seleniumhq.org/), you can start it with:

``` bash
Expand Down
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
version: '2'

services:
php:
build: docker
php: &php
build: docker/php
env_file:
- .env
environment:
GROUP_ID: ${GROUP_ID}
USER_ID: ${USER_ID}
SYMFONY_DEPRECATIONS_HELPER: ${SYMFONY_DEPRECATIONS_HELPER}
XDEBUG: ${XDEBUG}
XDEBUG_CONFIG: remote_host=${XDEBUG_HOST} remote_port=${XDEBUG_PORT} idekey=${XDEBUG_IDEKEY}
PHP_IDE_CONFIG: serverName=${IDE_SERVER_NAME}
volumes:
- ~/.composer:/var/www/.composer
- .:/var/www/html
- tmp:/tmp
hhvm:
<<: *php
build: docker/hhvm
selenium:
image: selenium/standalone-chrome:latest
volumes:
Expand Down
3 changes: 0 additions & 3 deletions docker/config/xdebug.ini

This file was deleted.

28 changes: 28 additions & 0 deletions docker/hhvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM hhvm/hhvm:latest

# APT packages
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

# HHVM configuration
RUN echo "hhvm.libxml.ext_entity_whitelist=file,http" >> /etc/hhvm/php.ini

# XDebug configuration
COPY config/xdebug.ini /var/www/xdebug.ini

# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin

# Bash
RUN chsh -s /bin/bash www-data

# Permissions
RUN chown www-data:www-data /var/www

# Workdir
WORKDIR /var/www/html

# Entrypoint
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
4 changes: 4 additions & 0 deletions docker/hhvm/config/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
xdebug.cli_color=1
xdebug.enable=1
xdebug.remote_autostart=1
xdebug.remote_enable=1
26 changes: 26 additions & 0 deletions docker/hhvm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -e

GROUP_ID=${GROUP_ID-1000}
USER_ID=${USER_ID-1000}
XDEBUG=${XDEBUG-0}

# Enable XDebug
if [ "$XDEBUG" = 1 ]; then
cat /var/www/xdebug.ini >> /etc/hhvm/php.ini
fi

# Remove XDebug temporary configuration
rm -f /var/www/xdebug.ini

# Permissions
groupmod -g ${GROUP_ID} www-data
usermod -u ${USER_ID} www-data

# Start bash or forward command
if [ "$1" = "bash" ]; then
su www-data
else
su www-data -c "$*"
fi
12 changes: 8 additions & 4 deletions docker/Dockerfile → docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ RUN apt-get update && apt-get install -y \
RUN docker-php-ext-install zip

# XDebug extensions
RUN pecl install xdebug && rm -rf /tmp/pear
COPY config/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& rm -rf /tmp/pear

# Bash
RUN chsh -s /bin/bash www-data
# XDebug configuration
COPY config/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin

# Bash
RUN chsh -s /bin/bash www-data

# Workdir
WORKDIR /var/www/html

Expand Down
2 changes: 2 additions & 0 deletions docker/php/config/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xdebug.cli_color=1
xdebug.remote_enable=1
6 changes: 3 additions & 3 deletions docker/entrypoint.sh → docker/php/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ USER_ID=${USER_ID-1000}
XDEBUG=${XDEBUG-0}

# Disable XDebug
if [ ! ${XDEBUG} = 1 ]; then
rm -f /usr/local/etc/php/conf.d/xdebug.ini
if [ ! "$XDEBUG" = 1 ]; then
rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
fi

# Permissions
groupmod -g ${GROUP_ID} www-data
usermod -u ${USER_ID} www-data

# Start bash or forward command
if [ $1 = "bash" ]; then
if [ "$1" = "bash" ]; then
su www-data
else
su www-data -c "$*"
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
<server name="BROWSER_NAME" value="chrome" />
<server name="SELENIUM_HOST" value="selenium" />
</php>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<filter>
<whitelist>
<directory>./</directory>
Expand Down
40 changes: 40 additions & 0 deletions travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -e

COMPOSER_PREFER_LOWEST=${COMPOSER_PREFER_LOWEST-false}
DOCKER_BUILD=${DOCKER_BUILD-false}
SYMFONY_VERSION=${SYMFONY_VERSION-2.3.*}

if [ "$DOCKER_BUILD" = true ]; then
cp .env.dist .env

docker-compose build
docker-compose run --rm php composer update --prefer-source

exit
fi

export DISPLAY=:99
/sbin/start-stop-daemon -Sbmq -p /tmp/xvfb_99.pid -x /usr/bin/Xvfb -- ${DISPLAY} -ac -screen 0, 1600x1200x24

curl http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.0.jar > selenium.jar
curl http://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip

java -jar selenium.jar -Dwebdriver.chrome.driver=./chromedriver > /dev/null 2>&1 &

composer self-update

composer require --no-update symfony/framework-bundle:${SYMFONY_VERSION}
composer require --no-update --dev symfony/form:${SYMFONY_VERSION}
composer require --no-update --dev symfony/templating:${SYMFONY_VERSION}
composer require --no-update --dev symfony/yaml:${SYMFONY_VERSION}

composer remove --no-update --dev friendsofphp/php-cs-fixer

if [[ "$SYMFONY_VERSION" = *dev* ]]; then
composer config minimum-stability dev
fi

composer update --prefer-source `if [ "$COMPOSER_PREFER_LOWEST" = true ]; then echo "--prefer-lowest --prefer-stable"; fi`
15 changes: 15 additions & 0 deletions travis/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

DOCKER_BUILD=${DOCKER_BUILD-false}

if [ "$DOCKER_BUILD" = false ]; then
vendor/bin/phpunit --configuration phpunit.travis.xml --coverage-clover build/clover.xml
fi

if [ "$DOCKER_BUILD" = true ]; then
docker-compose up -d
docker-compose run --rm php vendor/bin/phpunit
docker-compose run --rm hhvm vendor/bin/phpunit
fi
10 changes: 10 additions & 0 deletions travis/success.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

DOCKER_BUILD=${DOCKER_BUILD-false}

if [ "$DOCKER_BUILD" = false ]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/clover.xml
fi

0 comments on commit 5896f97

Please sign in to comment.