Skip to content

Commit

Permalink
[Docker] Add hhvm container (#275)
Browse files Browse the repository at this point in the history
* [Docker] Add hhvm container

* [Travis] Reorganize scripts

* [Travis] Add docker build

* [Travis] Fix docker build
  • Loading branch information
GeLoLabs committed Feb 7, 2017
1 parent f89d56c commit 6e82c3f
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .env.dist
@@ -1,7 +1,14 @@
# IDE
IDE_SERVER_NAME=ivory-ckeditor-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
@@ -1,4 +1,5 @@
/docker export-ignore
/travis export-ignore
/Tests export-ignore
.env.dist export-ignore
.gitattributes export-ignore
Expand Down
23 changes: 6 additions & 17 deletions .travis.yml
Expand Up @@ -18,26 +18,15 @@ env:
- SYMFONY_DEPRECATIONS_HELPER=weak
- SYMFONY_VERSION=2.3.*

install:
- composer self-update
- composer require --no-update symfony/framework-bundle:${SYMFONY_VERSION}
- composer require --no-update symfony/form:${SYMFONY_VERSION}
- if [[ "$SYMFONY_VERSION" =~ ^2\.[2-6] ]]; then composer require --no-update --dev symfony/asset:2.7.*; else composer require --no-update --dev symfony/asset:${SYMFONY_VERSION}; fi
- composer require --no-update --dev symfony/templating:${SYMFONY_VERSION}
- composer require --no-update --dev symfony/twig-bridge:${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 --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.2.* COMPOSER_PREFER_LOWEST=true
- php: 5.6
Expand Down
7 changes: 7 additions & 0 deletions Resources/doc/docker.rst
Expand Up @@ -44,6 +44,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`_, you can use:

.. code-block:: bash
$ docker-compose run --rm hhvm vendor/bin/phpunit
XDebug
------

Expand All @@ -56,3 +62,4 @@ If you want to use XDebug, make sure you have fully configured your `.env` file
.. _`Composer`: https://getcomposer.org/
.. _`Docker`: https://www.docker.com
.. _`Docker Compose`: https://docs.docker.com/compose/docker.rst
.. _`HHVM`: http://hhvm.com/
13 changes: 7 additions & 6 deletions docker-compose.yml
@@ -1,15 +1,16 @@
version: '2'

services:
php:
build: docker
php: &php
build: docker/php
env_file:
- .env
environment:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_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
hhvm:
<<: *php
build: docker/hhvm
3 changes: 0 additions & 3 deletions docker/config/xdebug.ini

This file was deleted.

28 changes: 28 additions & 0 deletions docker/hhvm/Dockerfile
@@ -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
@@ -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
@@ -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
Expand Up @@ -11,15 +11,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
@@ -0,0 +1,2 @@
xdebug.cli_color=1
xdebug.remote_enable=1
4 changes: 2 additions & 2 deletions docker/entrypoint.sh → docker/php/entrypoint.sh
Expand Up @@ -8,15 +8,15 @@ XDEBUG=${XDEBUG-0}

# Disable XDebug
if [ ! ${XDEBUG} = 1 ]; then
rm -f /usr/local/etc/php/conf.d/xdebug.ini
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
38 changes: 38 additions & 0 deletions travis/install.sh
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -e

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

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

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

exit
fi

composer self-update

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

if [[ "$SYMFONY_VERSION" =~ ^2\.[2-6] ]]; then
composer require --no-update --dev symfony/asset:2.7.*
else
composer require --no-update --dev symfony/asset:${SYMFONY_VERSION}
fi

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`
14 changes: 14 additions & 0 deletions travis/script.sh
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

DOCKER_BUILD=${DOCKER_BUILD=false}

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

if [ ${DOCKER_BUILD} = true ]; then
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
@@ -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 6e82c3f

Please sign in to comment.