Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
Lukasz Serwatka committed Aug 18, 2016
2 parents 499b771 + ff19137 commit 3aa14be
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 34 deletions.
23 changes: 16 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,46 @@ language: generic
services:
- docker

cache:
directories:
- $HOME/.composer/cache/files

env:
global:
- COMPOSE_FILE="doc/docker-compose/base-dev.yml:doc/docker-compose/selenium.yml"
- SYMFONY_ENV=behat
- SYMFONY_DEBUG=1
# list of behat arguments to test
matrix:
- ARGS="--profile=rest --suite=fullJson" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml"
- ARGS="--profile=rest --suite=fullXml" SYMFONY_ENV=behat SYMFONY_DEBUG=1
- ARGS="--profile=core" SYMFONY_ENV=behat SYMFONY_DEBUG=1
- TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/redis.yml:doc/docker-compose/selenium.yml"
- TEST_CMD="bin/behat -vv --profile=rest --suite=fullXml --tags=~@broken"
- TEST_CMD="bin/behat -vv --profile=core --tags=~@broken"
- TEST_CMD="bin/phpunit -v vendor/ezsystems/ezpublish-kernel/eZ/Bundle/EzPublishRestBundle/Tests/Functional" REST_BASIC_AUTH=1
- TEST_CMD="bin/behat -vv --profile=platformui --tags='@common'"

# test only master (+ Pull requests)
branches:
only:
- master
- "1.3"
- /^\d.\d+$/

# Update Docker and Docker Compose
before_install: ./bin/.travis/trusty/update_docker.sh

before_script:
# Internal auth token dedicated to testing with travis+composer on ezsystems repos, not for reuse!
- echo "{\"github-oauth\":{\"github.com\":\"d0285ed5c8644f30547572ead2ed897431c1fc09\"}}" > auth.json
- if [ "$REST_BASIC_AUTH" != "" ] ; then sed -i 's/# / /' app/config/security.yml ; fi
# In case of dev mode we'll need to install composer packages first
- docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit
# Run (start containers and execute install command)
- docker-compose up -d
#- docker ps
#- docker-compose logs

# execute behat as the script command, need to use sh to get right exit code (docker/compose/issues/3379)
# using behat.yml which is a copy of behat.yml.dist with hostnames update by docker-compose.behat.yml
script: docker-compose exec --user www-data app sh -c "php /scripts/wait_for_db.php; php bin/behat -vv $ARGS --tags=~@broken"
# Execute test command, need to use sh to get right exit code (docker/compose/issues/3379)
# Behat will use behat.yml which is a copy of behat.yml.dist with hostnames update by doc/docker-compose/selenium.yml
script: docker-compose exec --user www-data app sh -c "php /scripts/wait_for_db.php; php $TEST_CMD"

# disable mail notifications
notifications:
Expand Down
2 changes: 1 addition & 1 deletion app/config/cache_pool/singlememcached.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stash:
singlememcached:
drivers: [Memcache]
Memcache:
servers: [ {server: '%cache_host%', port: 11211} ]
servers: [ {server: '%cache_host%', port: '%cache_memcached_port%'} ]
2 changes: 1 addition & 1 deletion app/config/cache_pool/singleredis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stash:
singleredis:
drivers: [Redis]
Redis:
servers: [ {server: '%cache_host%', port: 6379} ]
servers: [ {server: '%cache_host%', port: '%cache_redis_port%'} ]
14 changes: 7 additions & 7 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ imports:
- { resource: default_parameters.yml }
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: env.php }
- { resource: env/docker.php }

# Configuration for Database connection, can have several connections used by eZ Repositories in ezplatform.yml
doctrine:
Expand Down Expand Up @@ -56,12 +56,12 @@ framework:
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection:
enabled: true
# Note: changing this will break legacy extensions that rely on the default name to alter AJAX requests
# See https://jira.ez.no/browse/EZP-20783
field_name: ezxform_token
form:
csrf_protection:
enabled: true
# Note: changing this will break legacy extensions that rely on the default name to alter AJAX requests
# See https://jira.ez.no/browse/EZP-20783
field_name: ezxform_token
validation: { enable_annotations: true }
# Place "eztpl" engine first intentionnally.
# This is to avoid template name parsing with Twig engine, refusing specific characters
Expand Down
3 changes: 3 additions & 0 deletions app/config/default_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ parameters:
cache_pool: "default"

cache_host: 127.0.0.1

cache_memcached_port: 11211
cache_redis_port: 6379
14 changes: 13 additions & 1 deletion app/config/env.php → app/config/env/docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader;

if (getenv('DATABASE_HOST') === false) {
// Return if not DATABASE_HOST is set as that is needed to get things running with docker (shouldn't be on localhost)
return;
}

if ($value = getenv('SYMFONY_SECRET')) {
$container->setParameter('secret', $value);
}
Expand Down Expand Up @@ -79,6 +84,13 @@
$container->setParameter('cache_host', $host);
}

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/cache_pool'));
// Optional port settings in case not default
if ($host = getenv('CACHE_MEMCACHED_PORT')) {
$container->setParameter('cache_memcached_port', $host);
} elseif ($host = getenv('CACHE_REDIS_PORT')) {
$container->setParameter('cache_redis_port', $host);
}

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../cache_pool'));
$loader->load($pool . '.yml');
}
4 changes: 2 additions & 2 deletions app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ security:
providers:
ezpublish:
id: ezpublish.security.user_provider
# in_memory:
# memory: ~
#! in_memory:
#! memory: ~

firewalls:
dev:
Expand Down
11 changes: 6 additions & 5 deletions bin/.travis/trusty/update_docker.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env sh

# Update package info and selectively update docker-engine (and keep old travis specific config file)
sudo apt-get update
sudo apt-get --reinstall -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine
docker -v
#disabled to save startup time as last travis image already have docker v1.12.0
#sudo apt-get update
#sudo apt-get --reinstall -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine
#docker -v

# If we need to pin it to a given version:
# sudo apt-get --reinstall -y [...] install docker-engine=1.11.0-0~jessie
# http://apt.dockerproject.org/repo/dists/debian-jessie/main/binary-amd64/Packages


DOCKER_COMPOSE_VERSION="1.7.1"
DOCKER_COMPOSE_VERSION="1.8.0"
echo "\nUpdating Docker Compose to ${DOCKER_COMPOSE_VERSION}"
sudo rm /usr/local/bin/docker-compose
sudo rm -f /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"tedivm/stash-bundle": "~0.4",
"ezsystems/ezpublish-kernel": "^6.4@dev",
"ezsystems/ezpublish-kernel": "^6.5@dev",
"ezsystems/repository-forms": "^1.3@dev",
"ezsystems/ezplatform-solr-search-engine": "^1.0@dev",
"ezsystems/ezplatform-solr-search-engine": "^1.1@dev",
"ezsystems/platform-ui-bundle": "^1.5@dev",
"ezsystems/platform-ui-assets-bundle": "@alpha",
"ezsystems/ez-support-tools": "~0.1.0@dev",
"ezsystems/studio-ui-bundle": "^1.5@dev",
"ezsystems/ezstudio-notifications": "^1.2@dev",
Expand Down
32 changes: 26 additions & 6 deletions doc/docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
This setup requires Docker Compose 1.7 or higher, and Docker 1.10 or higher. Defaults are set in `.env`, and
files to ignore are set in `.dockerignore`. By default `.env` specifies that production image is built and setup for use.

#### Concept: Docker Compose "Building blocks" for eZ Platform

The current Docker Compose files are made to be mixed and matched togtehr as you'd like. Currently available:
- base-prod.yml _(required, always needs to be first, contains: db, web and app container)_
- base-dev.yml _(alternative to `base-prod.yml`, same applies here if used)_
- redis.yml _(optional, adds redis service and appends config to app)_
- solr.yml _(optional, work in progress config to add solr service and configure app for it, for testing only)_
- blackfire.yml _(optional, adds blackfire service and lets you trigger profiling against the setup)_
- selenium.yml _(optional, always needs to be last, adds selenium service and appends config to app)_


These can be used with `-f` argument on docker-compose, like:
```bash
docker-compose -f doc/docker-compose/base-prod.yml -f doc/docker-compose/redis.yml up -d --force-recreate
```

However below environment variable `COMPOSE_FILE` is used instead since this is also what is used to have a default in
`.env` file at root of the project.


#### Before you begin: Install Docker & Docker-Compose

Before jumping into steps below, make sure you have recent versions of [Docker & Docker-Compose](https://www.docker.com/)
Expand Down Expand Up @@ -145,15 +165,15 @@ After this you can re run the production or dev steps to setup containers again

### Cleanup

Once you are done with your setup, you can stop it, and remove the involved containers.
```sh
Once you are done with your setup, you can stop it, and remove the involved containers.
```sh
docker-compose down -v
```
```

And if you have defined any environment variables you can unset them using:
```sh
And if you have defined any environment variables you can unset them using:
```sh
unset COMPOSE_FILE SYMFONY_ENV SYMFONY_DEBUG COMPOSE_DIR COMPOSER_HOME

# To unset blackfire variables
unset BLACKFIRE_SERVER_ID BLACKFIRE_SERVER_TOKEN
```
```
2 changes: 1 addition & 1 deletion doc/docker-compose/blackfire.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '2'
# Blackfire agent config, depends on at least prod.yml, but can also be combined with others as it is standalone service
# Blackfire agent config, to be appended after base-prod or base-dev config.
# You'll need to export the two blackfire server variables before you can use this.

services:
Expand Down
2 changes: 1 addition & 1 deletion doc/docker-compose/redis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '2'
# Redis config, to be appended to prod, prod+dev, ..., but before selenium.yml
# Redis config, to be appended after base-prod or base-dev, ..., but before selenium.yml

services:
app:
Expand Down
23 changes: 23 additions & 0 deletions doc/docker-compose/solr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '2'
# Solr config, to be appended after base-prod or base-dev, ..., but before selenium.yml
#
# This service will migrate to use offical Solr image and use entrypoint once Solr bundle supports SOLR6+.
#
# NOTE: You'll need to manually reindex the solr index when booting this as we don't have entrypoint for solr yet.
# (Unless you use ezplatform:install command which indexes for you)

services:
app:
depends_on:
- solr
environment:
- SEARCH_ENGINE=solr
- SOLR_DSN=http://solr:8983/solr

solr:
image: makuk66/docker-solr:4.10.4
volumes_from:
- app:ro
environment:
- EZ_SOLR_CONF="/var/www/vendor/ezsystems/ezplatform-solr-search-engine/lib/Resources/config/solr"
command: /bin/bash -c "cp -R $${EZ_SOLR_CONF}/* /opt/solr/example/solr/collection1/conf/ && /opt/solr/bin/solr start -f"

0 comments on commit 3aa14be

Please sign in to comment.