Skip to content

Commit

Permalink
Merge remote-tracking branch ‘ezplatform/1.11' into ‘ezplatform-ee/1.11’
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
Lukasz Serwatka committed Sep 8, 2017
2 parents afb4f67 + e26b066 commit d5ea654
Show file tree
Hide file tree
Showing 26 changed files with 216 additions and 90 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -42,6 +42,7 @@ web/bundles/
web/css/
web/js/
web/uploads/
web/fonts/

# Assets managed by Bower
web/assets/vendor/
Expand Down
9 changes: 4 additions & 5 deletions .env
@@ -1,6 +1,5 @@
# Allows us to set default values of env variables, see: https://docs.docker.com/compose/env-file/
# On Docker Compose v1.7.0 file separator if defining several is different from Win and nix, so we just use one for default prod setup
COMPOSE_FILE=doc/docker-compose/base-prod.yml
COMPOSE_FILE=doc/docker/base-dev.yml
COMPOSE_DIR=.

# You'll need to adjust this for Windows and XDB Linux systems: https://getcomposer.org/doc/03-cli.md#composer-home
Expand All @@ -13,9 +12,9 @@ DATABASE_NAME=ezp
PHP_IMAGE=ezsystems/php:7.1-v1
PHP_IMAGE_DEV=ezsystems/php:7.1-v1-dev
NGINX_IMAGE=nginx:stable
MYSQL_IMAGE=mariadb:10.1
SELENIUM_IMAGE=selenium/standalone-firefox:2.53.1
REDIS_IMAGE=redis
MYSQL_IMAGE=healthcheck/mariadb
SELENIUM_IMAGE=selenium/standalone-chrome-debug:3.4.0
REDIS_IMAGE=healthcheck/redis

# App image name for use if you intend to push it to docker registry/hub.
APP_PROD_IMAGE=my-ez-app
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -28,13 +28,14 @@
/ezpublish_legacy
/app/config/parameters.yml
/app/bootstrap.php.cache
/doc/docker-compose/entrypoint/*/*.sql
/doc/docker/entrypoint/*/*.sql
/web/index_treemenu.php
/web/index_rest.php
/web/index_cluster.php
/web/bundles/
/web/css/
/web/js/
web/fonts/
/web/design
/web/extension
/web/share
Expand Down
16 changes: 9 additions & 7 deletions .travis.yml
Expand Up @@ -11,16 +11,16 @@ cache:

env:
global:
- COMPOSE_FILE="doc/docker-compose/base-dev.yml:doc/docker-compose/selenium.yml"
- COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml"
- SYMFONY_ENV=behat
- SYMFONY_DEBUG=1
# list of behat arguments to test
matrix:
- TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.yml:doc/docker-compose/selenium.yml" WEB_HOST="varnish"
- TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" COMPOSE_FILE="doc/docker/base-prod.yml:doc/docker/varnish.yml:doc/docker/selenium.yml" WEB_HOST="varnish"
- 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"
- TEST_CMD="bin/behat -vv --profile=platformui --tags='@common'" COMPOSE_FILE="doc/docker-compose/base-dev.yml:doc/docker-compose/redis.yml:doc/docker-compose/selenium.yml"
- TEST_CMD="bin/behat -vv --profile=platformui --tags='@common'" COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/redis.yml:doc/docker/selenium.yml"

# test only master (+ Pull requests)
branches:
Expand All @@ -35,19 +35,21 @@ 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
# 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
- docker-compose -f doc/docker/install.yml up --abort-on-container-exit
# Run (start containers and execute install command)
- docker-compose up -d
#- docker ps
#- docker-compose logs

# 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
# Behat will use behat.yml which is a copy of behat.yml.dist with hostnames update by doc/docker/selenium.yml
script: docker-compose exec --user www-data app sh -c "php /scripts/wait_for_db.php; php $TEST_CMD"

after_failure:
# Will show us the full log of container's main processes (not counting shell process above running php and behat)
- docker-compose logs -t --tail="all"
# Will show us the last bit of the log of container's main processes
# (not counting shell process above running php and behat)
# NOTE: errors during docker setup of travis build won't show up here (can't output all as it is too much in debug/verbose mode)
- docker-compose logs -t --tail=15
# Will show us what is up, and how long it's been up
- docker ps -s

Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Expand Up @@ -24,6 +24,3 @@ RUN mkdir -p web/var \
# Remove composer cache to avoid it taking space in image
&& rm -rf ~/.composer/*/* \
&& [ "$REMOVE_AUTH" = "1" ] && rm -f auth.json

# Declare volumes so it an can be shared with other containers
VOLUME /var/www /var/www/web/var
2 changes: 1 addition & 1 deletion RUNNING_BEHAT.md
@@ -1,7 +1,7 @@
# Running the behat features

*Note: If you want there is a way to run Behat using Docker setup, where you won't have to install any software other
then Docker. See `doc/docker-compose/README.md` for further info.*
then Docker. See `doc/docker/README.md` for further info.*

## Install selenium server
Download the last version of the selenium server on the [download page](http://www.seleniumhq.org/download/).
Expand Down
10 changes: 8 additions & 2 deletions behat.yml.dist
Expand Up @@ -6,10 +6,16 @@ default:
Behat\MinkExtension:
base_url: 'http://localhost'
goutte: ~
javascript_session: selenium2
selenium2:
browser: chrome
wd_host: 'http://localhost:4444/wd/hub'
javascript_session: selenium2
browser_name: firefox
capabilities:
extra_capabilities:
chromeOptions:
args:
- "--window-size=1440,1080"
- "--no-sandbox"

Behat\Symfony2Extension:
kernel:
Expand Down
8 changes: 6 additions & 2 deletions bin/.travis/trusty/setup_from_external_repo.sh
Expand Up @@ -9,7 +9,7 @@
## Example use:
#
# env:
# - COMPOSE_FILE="doc/docker-compose/prod.yml:doc/docker-compose/selenium.yml"
# - COMPOSE_FILE="doc/docker/prod.yml:doc/docker/selenium.yml"
#
# before_install:
# - git fetch --unshallow && git checkout -b tmp_travis_branch
Expand Down Expand Up @@ -39,6 +39,10 @@ ls -al .
echo "> Modify composer.json to point to local checkout"
composer config repositories.tmp_travis_folder git ${HOME}/build/ezplatform/tmp_travis_folder


# Setup symlink for doc/docker-compose folder for compatibility with older package branches using this
ln -s docker doc/docker-compose

if [ "$RUN_INSTALL" = "1" ] ; then
# TODO: avoid using composer on host so image don't need to be PHP image, needed atm as .
# TODO: dockerignore or something strips info needed for composer to be able to find tmp_travis_branch
Expand All @@ -62,7 +66,7 @@ if [ "$RUN_INSTALL" = "1" ] ; then
find app/cache app/logs web/var -type f | xargs chmod -R 664
# Do NOT use this for your prod setup, this is done like this for behat
sudo chown -R www-data:www-data app/config src
#docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit
#docker-compose -f doc/docker/install.yml up --abort-on-container-exit
fi

INSTALL_EZ_INSTALL_TYPE=${INSTALL_EZ_INSTALL_TYPE:-clean}
Expand Down
4 changes: 2 additions & 2 deletions bin/.travis/trusty/update_docker.sh
Expand Up @@ -3,7 +3,7 @@
# Update package info and selectively update docker-engine (and keep old travis specific config file)
docker -v
sudo apt-get update
sudo apt-get --reinstall -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine
sudo apt-get --reinstall -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-ce
docker -v

# If we need to pin it to a given version:
Expand All @@ -12,7 +12,7 @@ docker -v


docker-compose -v
DOCKER_COMPOSE_VERSION="1.13.0"
DOCKER_COMPOSE_VERSION="1.14.0"
echo "\nUpdating Docker Compose to ${DOCKER_COMPOSE_VERSION}"
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
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -55,7 +55,8 @@
"ezsystems/date-based-publisher": "^1.0@dev",
"ezsystems/content-on-the-fly-prototype": "~0.1.7",
"ezsystems/ezplatform-multi-file-upload": "^0.1.0@dev",
"willdurand/js-translation-bundle": "^2.6.4"
"willdurand/js-translation-bundle": "^2.6.4",
"roave/security-advisories": "dev-master"
},
"require-dev": {
"ezsystems/ezplatform-i18n": "^1.0@dev",
Expand Down
19 changes: 0 additions & 19 deletions doc/docker-compose/Dockerfile-varnish

This file was deleted.

43 changes: 43 additions & 0 deletions doc/docker/Dockerfile-nginx
@@ -0,0 +1,43 @@
FROM ezsystems/php:7.1-v1 as web-build

ENV SYMFONY_ENV=prod

# Copy in project files into work dir
COPY . /var/www

# Create asset directories that might not exists
RUN if [ ! -d /var/www/web/bundles ]; then mkdir /var/www/web/bundles; fi
RUN if [ ! -d /var/www/web/css ]; then mkdir /var/www/web/css; fi
RUN if [ ! -d /var/www/web/fonts ]; then mkdir /var/www/web/fonts; fi
RUN if [ ! -d /var/www/web/js ]; then mkdir /var/www/web/js; fi
RUN if [ ! -d /var/www/web/assets ]; then mkdir /var/www/web/assets; fi

# Generate assets using hard copy as we need to copy them over to resulting image
RUN composer config extra.symfony-assets-install hard
RUN composer run-script post-install-cmd --no-interaction


# Copy over just the files we want in second stage, so resulting stage only has assets
# and vhost config in as few layers as possible
FROM nginx:stable as web-multilayers

COPY bin/vhost.sh /var/www/bin/vhost.sh
COPY doc/nginx/vhost.template /var/www/doc/nginx/vhost.template

# Auto generated assets
COPY --from=web-build /var/www/web/bundles /var/www/web/bundles
COPY --from=web-build /var/www/web/css /var/www/web/css
COPY --from=web-build /var/www/web/fonts /var/www/web/fonts
COPY --from=web-build /var/www/web/js /var/www/web/js

# User provided assets
COPY --from=web-build /var/www/web/assets /var/www/web/assets


# In third stage build the resulting image
FROM nginx:stable

COPY --from=web-multilayers /var/www /var/www
COPY doc/nginx/ez_params.d /etc/nginx/ez_params.d

CMD /bin/bash -c "cd /var/www && bin/vhost.sh --template-file=doc/nginx/vhost.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
File renamed without changes.
54 changes: 54 additions & 0 deletions doc/docker/Dockerfile-varnish
@@ -0,0 +1,54 @@
FROM debian:stretch-slim

ENV VARNISH_MALLOC_SIZE="256M" \
DEBIAN_FRONTEND=noninteractive

ARG PACKAGECLOUD_URL=https://packagecloud.io/install/repositories/varnishcache/varnish5/script.deb.sh
ARG VARNISH_MODULES_VERSION=0.12.1

# Use offical packages from Varnish and build with varnish-modules mainly for xkey
# see: https://github.com/varnish/varnish-modules/tree/master/docs
RUN set -xe \
&& buildDeps=" \
make \
automake \
autotools-dev \
libedit-dev \
libjemalloc-dev \
libncurses-dev \
libpcre3-dev \
libtool \
pkg-config \
python-docutils \
python-sphinx \
varnish-dev \
" \
# Update apt and get dependencies
&& apt-get update -q -y \
&& apt-get install -q -y --no-install-recommends ca-certificates curl \
\
# Get offical Varnish package
&& curl -s ${PACKAGECLOUD_URL} | bash \
&& apt-get install -q -y --allow-unauthenticated --no-install-recommends varnish $buildDeps \
\
# Install varnish modules
&& curl -A "Docker" -o /tmp/varnish-modules.tar.gz -D - -L -s https://download.varnish-software.com/varnish-modules/varnish-modules-${VARNISH_MODULES_VERSION}.tar.gz \
&& tar zxpf /tmp/varnish-modules.tar.gz -C /tmp/ \
&& cd /tmp/varnish-modules-${VARNISH_MODULES_VERSION} \
&& ./configure \
&& make \
# && make check \
&& make install \
&& rm -f /tmp/varnish-modules.tar.gz && rm -Rf /tmp/varnish-modules \
\
# Cleanup apt cache and remove build packages
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \
&& rm -rf /var/lib/apt/lists/*

COPY doc/varnish/vcl/varnish4.vcl /etc/varnish/default.vcl
COPY doc/docker/entrypoint/varnish/parameters.vcl /etc/varnish/parameters.vcl

EXPOSE 80 6082

# CMD in shell form to be able to use env variables here
CMD varnishd -F -a :80 -T :6082 -f /etc/varnish/default.vcl -s malloc,${VARNISH_MALLOC_SIZE}
26 changes: 13 additions & 13 deletions doc/docker-compose/README.md → doc/docker/README.md
Expand Up @@ -14,8 +14,9 @@ Mac/Windows use of shared folders. This is a know issue and nothing we intend to

## Overview

This setup requires Docker Compose 1.9 or higher, and Docker 1.12 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.
This setup currently requires Docker Compose 1.14 and Docker 17.06 or higher. Defaults are set in `.env`, and
files to ignore are set in `.dockerignore`. By default `.env` specifies that dev setup is used.

_**NB:** For this and other reasons all docker-compose commands **must** be executed from root of your project directory._

#### Before you begin: Install Docker & Docker-Compose
Expand All @@ -40,7 +41,7 @@ The current Docker Compose files are made to be mixed and matched together for Q

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/blackfire.yml up -d --force-recreate
docker-compose -f doc/docker/base-prod.yml -f doc/docker/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
Expand All @@ -53,11 +54,13 @@ However below environment variable `COMPOSE_FILE` is used instead since this is

From root of your projects clone of this distribution, [setup composer auth.json](#composer) and execute the following:
```sh
export COMPOSE_FILE=doc/docker/base-prod.yml

# Optional step if you'd like to use blackfire with the setup, change <id> and <token> with your own values
#export COMPOSE_FILE=doc/docker-compose/base-prod.yml:doc/docker-compose/blackfire.yml BLACKFIRE_SERVER_ID=<id> BLACKFIRE_SERVER_TOKEN=<token>
#export COMPOSE_FILE=doc/docker/base-prod.yml:doc/docker/blackfire.yml BLACKFIRE_SERVER_ID=<id> BLACKFIRE_SERVER_TOKEN=<token>

# First time: Install setup, and generate database dump:
docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit
docker-compose -f doc/docker/install.yml up --abort-on-container-exit

# Boot up full setup:
docker-compose up -d --force-recreate
Expand All @@ -73,13 +76,11 @@ by default under the hood, which leads to much slower IO performance.*

From root of your projects clone of this distribution, [setup composer auth.json](#composer) and execute the following:
```sh
export COMPOSE_FILE=doc/docker-compose/base-dev.yml

# Optional: If you use Docker Machine with NFS, you'll need to specify where project is, & give composer a valid directory.
#export COMPOSE_DIR=/data/SOURCES/MYPROJECTS/ezplatform/doc/docker-compose COMPOSER_HOME=/tmp
#export COMPOSE_DIR=/data/SOURCES/MYPROJECTS/ezplatform/doc/docker COMPOSER_HOME=/tmp

# First time: Install setup, and generate database dump:
docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit
docker-compose -f doc/docker/install.yml up --abort-on-container-exit

# Boot up full setup:
docker-compose up -d --force-recreate
Expand All @@ -97,10 +98,10 @@ image to Docker Hub/Registry.*

From root of your projects clone of this distribution, [setup composer auth.json](#composer) and execute the following:
```sh
export COMPOSE_FILE=doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml
export COMPOSE_FILE=doc/docker/base-prod.yml:doc/docker/selenium.yml

# First time: Install setup, and generate database dump:
docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit
docker-compose -f doc/docker/install.yml up --abort-on-container-exit

# Boot up full setup:
docker-compose up -d --force-recreate
Expand Down Expand Up @@ -153,11 +154,10 @@ docker-compose ps

### Database dumps

Database dump is placed in `doc/docker-compose/entrypoint/mysql/`, this folder is used my mysql/mariadb which will execute
Database dump is placed in `doc/docker/entrypoint/mysql/`, this folder is used my mysql/mariadb which will execute
everything inside the folder. This means there should only be data represent one install in the folder at any given time.



### Updating service images

To updated the used service images, you can run:
Expand Down

0 comments on commit d5ea654

Please sign in to comment.