From 17f3147c51a6ca5146152851cfb4a26037b67fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Sat, 29 Oct 2016 01:06:27 +0200 Subject: [PATCH 01/15] [WIP][Docker] Add docker support for using varnish --- .../entrypoint/varnish/varnish4.vcl | 221 ++++++++++++++++++ doc/docker-compose/varnish.yml | 30 +++ 2 files changed, 251 insertions(+) create mode 100644 doc/docker-compose/entrypoint/varnish/varnish4.vcl create mode 100644 doc/docker-compose/varnish.yml diff --git a/doc/docker-compose/entrypoint/varnish/varnish4.vcl b/doc/docker-compose/entrypoint/varnish/varnish4.vcl new file mode 100644 index 0000000000..7be2e95294 --- /dev/null +++ b/doc/docker-compose/entrypoint/varnish/varnish4.vcl @@ -0,0 +1,221 @@ +// Varnish 4 style - eZ 5.4+ / 2014.09+ +// Complete VCL example + +vcl 4.0; + +// Our Backend - Assuming that web server is listening on port 80 +// Replace the host to fit your setup +backend ezplatform { + .host = "web"; + .port = "80"; +} + +// ACL for invalidators IP +acl invalidators { + "127.0.0.1"; + "172.16.0.0"/20; + "app"; +} + +// ACL for debuggers IP +acl debuggers { + "127.0.0.1"; + "172.16.0.0"/20; +} + +// Called at the beginning of a request, after the complete request has been received +sub vcl_recv { + + // Set the backend + set req.backend_hint = ezplatform; + + // Advertise Symfony for ESI support + set req.http.Surrogate-Capability = "abc=ESI/1.0"; + + // Add a unique header containing the client address (only for master request) + // Please note that /_fragment URI can change in Symfony configuration + if (!req.url ~ "^/_fragment") { + if (req.http.x-forwarded-for) { + set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; + } else { + set req.http.X-Forwarded-For = client.ip; + } + } + + // Trigger cache purge if needed + call ez_purge; + + // Don't cache requests other than GET and HEAD. + if (req.method != "GET" && req.method != "HEAD") { + return (pass); + } + + // Normalize the Accept-Encoding headers + if (req.http.Accept-Encoding) { + if (req.http.Accept-Encoding ~ "gzip") { + set req.http.Accept-Encoding = "gzip"; + } elsif (req.http.Accept-Encoding ~ "deflate") { + set req.http.Accept-Encoding = "deflate"; + } else { + unset req.http.Accept-Encoding; + } + } + + // Don't cache Authenticate & Authorization + // You may remove this when using REST API with basic auth. + if (req.http.Authenticate || req.http.Authorization) { + if (client.ip ~ debuggers) { + set req.http.X-Debug = "Not Cached according to configuration (Authorization)"; + } + return (hash); + } + + // Do a standard lookup on assets + // Note that file extension list below is not extensive, so consider completing it to fit your needs. + if (req.url ~ "\.(css|js|gif|jpe?g|bmp|png|tiff?|ico|img|tga|wmf|svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|zip|gz|pdf|ttf|eot|wof)$") { + return (hash); + } + + // Retrieve client user hash and add it to the forwarded request. + call ez_user_hash; + + // If it passes all these tests, do a lookup anyway. + return (hash); +} + +// Called when the requested object has been retrieved from the backend +sub vcl_backend_response { + + if (bereq.http.accept ~ "application/vnd.fos.user-context-hash" + && beresp.status >= 500 + ) { + return (abandon); + } + + // Optimize to only parse the Response contents from Symfony + if (beresp.http.Surrogate-Control ~ "ESI/1.0") { + unset beresp.http.Surrogate-Control; + set beresp.do_esi = true; + } + + // Allow stale content, in case the backend goes down or cache is not fresh any more + // make Varnish keep all objects for 1 hours beyond their TTL + set beresp.grace = 1h; +} + +// Handle purge +// You may add FOSHttpCacheBundle tagging rules +// See http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html#id4 +sub ez_purge { + + if (req.method == "BAN") { + if (!client.ip ~ invalidators) { + return (synth(405, "Method Not Allowed")); + } + + if (req.http.X-Location-Id) { + ban("obj.http.X-Location-Id ~ " + req.http.X-Location-Id); + if (client.ip ~ debuggers) { + set req.http.X-Debug = "Ban done for content connected to LocationId " + req.http.X-Location-Id; + } + return (synth(200, "Banned")); + } + } +} + +// Sub-routine to get client user hash, for context-aware HTTP cache. +sub ez_user_hash { + + // Prevent tampering attacks on the hash mechanism + if (req.restarts == 0 + && (req.http.accept ~ "application/vnd.fos.user-context-hash" + || req.http.x-user-hash + ) + ) { + return (synth(400)); + } + + if (req.restarts == 0 && (req.method == "GET" || req.method == "HEAD")) { + // Get User (Context) hash, for varying cache by what user has access to. + // https://doc.ez.no/display/EZP/Context+aware+HTTP+cache + + // Anonymous user w/o session => Use hardcoded anonymous hash to avoid backend lookup for hash + if (req.http.Cookie !~ "eZSESSID" && !req.http.authorization) { + // You may update this hash with the actual one for anonymous user + // to get a better cache hit ratio across anonymous users. + // Note: You should then update it every time anonymous user rights change. + set req.http.X-User-Hash = "38015b703d82206ebc01d17a39c727e5"; + } + // Pre-authenticate request to get shared cache, even when authenticated + else { + set req.http.x-fos-original-url = req.url; + set req.http.x-fos-original-accept = req.http.accept; + set req.http.x-fos-original-cookie = req.http.cookie; + // Clean up cookie for the hash request to only keep session cookie, as hash cache will vary on cookie. + set req.http.cookie = ";" + req.http.cookie; + set req.http.cookie = regsuball(req.http.cookie, "; +", ";"); + set req.http.cookie = regsuball(req.http.cookie, ";(eZSESSID[^=]*)=", "; \1="); + set req.http.cookie = regsuball(req.http.cookie, ";[^ ][^;]*", ""); + set req.http.cookie = regsuball(req.http.cookie, "^[; ]+|[; ]+$", ""); + + set req.http.accept = "application/vnd.fos.user-context-hash"; + set req.url = "/_fos_user_context_hash"; + + // Force the lookup, the backend must tell how to cache/vary response containing the user hash + + return (hash); + } + } + + // Rebuild the original request which now has the hash. + if (req.restarts > 0 + && req.http.accept == "application/vnd.fos.user-context-hash" + ) { + set req.url = req.http.x-fos-original-url; + set req.http.accept = req.http.x-fos-original-accept; + set req.http.cookie = req.http.x-fos-original-cookie; + + unset req.http.x-fos-original-url; + unset req.http.x-fos-original-accept; + unset req.http.x-fos-original-cookie; + + // Force the lookup, the backend must tell not to cache or vary on the + // user hash to properly separate cached data. + + return (hash); + } +} + +sub vcl_deliver { + // On receiving the hash response, copy the hash header to the original + // request and restart. + if (req.restarts == 0 + && resp.http.content-type ~ "application/vnd.fos.user-context-hash" + ) { + set req.http.x-user-hash = resp.http.x-user-hash; + + return (restart); + } + + // If we get here, this is a real response that gets sent to the client. + + // Remove the vary on context user hash, this is nothing public. Keep all + // other vary headers. + set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *x-user-hash *", ""); + set resp.http.Vary = regsub(resp.http.Vary, "^, *", ""); + if (resp.http.Vary == "") { + unset resp.http.Vary; + } + + // Sanity check to prevent ever exposing the hash to a client. + unset resp.http.x-user-hash; + + if (client.ip ~ debuggers) { + if (obj.hits > 0) { + set resp.http.X-Cache = "HIT"; + set resp.http.X-Cache-Hits = obj.hits; + } else { + set resp.http.X-Cache = "MISS"; + } + } +} diff --git a/doc/docker-compose/varnish.yml b/doc/docker-compose/varnish.yml new file mode 100644 index 0000000000..3ed54c7784 --- /dev/null +++ b/doc/docker-compose/varnish.yml @@ -0,0 +1,30 @@ +version: '2' +# Simple single server setup for prod + +services: + app: + environment: + - SYMFONY_HTTP_CACHE=0 + - SYMFONY_TRUSTED_PROXIES=varnish +# @todo Add env variable taken into account by eZ Platform for configuring varnish purging + + varnish: + image: kardasz/varnish + ports: + - "8081:80" + depends_on: + - web + volumes: + - ${COMPOSE_DIR}/entrypoint/varnish/varnish4.vcl:/etc/varnish/default.vcl:ro + + +## DEBUG?? +# In need of debugging all request going to Varnish, use varnishlog, example: +# docker-compose exec varnish varnishlog -c -i ReqURL,ReqMethod -I ReqHeader:X-Location-Id +# Or more relevant only BAN's with all info: +# docker-compose exec varnish varnishlog -g request -q "ReqMethod eq 'BAN'" +# +# But before doing that check that http and not local purge client is set: +# docker-compose exec app app/console --env=dev debug:container ezpublish.http_cache.purge_client +# +# And if in prod make sure you have rebuilt app container on code changes ;) From 28fa713f3b6cbd35e999cc1bd46d1a3ad4728e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Sat, 29 Oct 2016 17:57:24 +0200 Subject: [PATCH 02/15] [Docker] Make it possible to inject varnish settings for purge server Conflicts: doc/docker-compose/varnish.yml --- app/config/default_parameters.yml | 4 ++++ app/config/env/docker.php | 6 ++++++ app/config/ezplatform.yml | 7 +++++++ doc/docker-compose/varnish.yml | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/config/default_parameters.yml b/app/config/default_parameters.yml index 6710401616..85bfeb1d90 100644 --- a/app/config/default_parameters.yml +++ b/app/config/default_parameters.yml @@ -28,3 +28,7 @@ parameters: cache_memcached_port: 11211 cache_redis_port: 6379 + + # Settings for HttpCache + purge_type: "local" + purge_server: "http://my.varnish.server:80" diff --git a/app/config/env/docker.php b/app/config/env/docker.php index 79ca6d6cb5..6eb6833f86 100644 --- a/app/config/env/docker.php +++ b/app/config/env/docker.php @@ -94,3 +94,9 @@ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../cache_pool')); $loader->load($pool . '.yml'); } + +// HttpCache setting (for configuring Varnish purging) +if ($purgeServer = getenv('HTTPCACHE_PURGE_SERVER')) { + $container->setParameter('purge_type', 'http'); + $container->setParameter('purge_server', $purgeServer); +} diff --git a/app/config/ezplatform.yml b/app/config/ezplatform.yml index edc4d2c479..34d3ada8b8 100644 --- a/app/config/ezplatform.yml +++ b/app/config/ezplatform.yml @@ -1,4 +1,8 @@ ezpublish: + # HttpCache settings, By default 'local' (Symfony HttpCache Proxy), setting it to 'http' you can point it to Varnish + http_cache: + purge_type: %purge_type% + # Repositories configuration, setup default repository to support solr if enabled repositories: default: @@ -29,3 +33,6 @@ ezpublish: # so removing eng-GB from this list may lead to errors or content not being shown, unless you change # all eng-GB data to other locales first. languages: [eng-GB] + # HttpCache purge server(s) setting, eg Varnish, for when ezpublish.http_cache.purge_type is set to 'http'. + http_cache: + purge_servers: ["%purge_server%"] diff --git a/doc/docker-compose/varnish.yml b/doc/docker-compose/varnish.yml index 3ed54c7784..69918002e6 100644 --- a/doc/docker-compose/varnish.yml +++ b/doc/docker-compose/varnish.yml @@ -6,7 +6,7 @@ services: environment: - SYMFONY_HTTP_CACHE=0 - SYMFONY_TRUSTED_PROXIES=varnish -# @todo Add env variable taken into account by eZ Platform for configuring varnish purging + - HTTPCACHE_PURGE_SERVER=http://varnish varnish: image: kardasz/varnish From 817a037c52305e29c7b90f14443fc092e51d4bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Sat, 29 Oct 2016 17:16:57 +0200 Subject: [PATCH 03/15] [Docker] Don't ignore .git folders in vendor dirs, composer will need it on dev --- .dockerignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index b3adbe2670..8dbb1db2d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,7 +3,8 @@ ### GIT files .git -vendor/*/*/.git +# Skipped as it makes build very slow and since it is needed by composer when working on dev branches +#vendor/*/*/.git ### Symfony template # Cache and logs (Symfony2) From 1e0e73f7bc087a82e7405c053c8cb815521b7b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Tue, 1 Nov 2016 11:33:55 +0100 Subject: [PATCH 04/15] [Travis] Enable BDD testing with Varnish --- .env | 5 +++++ .travis.yml | 4 ++-- doc/docker-compose/selenium.yml | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.env b/.env index f5b08cdeaf..45642a7d02 100644 --- a/.env +++ b/.env @@ -25,3 +25,8 @@ APP_DOCKER_FILE=Dockerfile # Install config INSTALL_EZ_INSTALL_TYPE=clean + +# Behat / Selenium config +EZP_TEST_REST_HOST=web +BEHAT_SELENIUM_HOST=selenium +BEHAT_WEB_HOST=web \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8d551c8dba..fbd0034945 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ env: - SYMFONY_DEBUG=1 # list of behat arguments to test matrix: - # Disabled until failures on BD tests with redis is solved / figured out + # Disabled until failures on BDD tests with redis is solved / figured out #- 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=fullJson --tags=~@broken" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml" + - TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" BEHAT_WEB_HOST="varnish" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.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" diff --git a/doc/docker-compose/selenium.yml b/doc/docker-compose/selenium.yml index cdd9310b5e..cab7c02ed8 100644 --- a/doc/docker-compose/selenium.yml +++ b/doc/docker-compose/selenium.yml @@ -16,6 +16,6 @@ services: depends_on: - selenium environment: - - EZP_TEST_REST_HOST=web - - BEHAT_SELENIUM_HOST=selenium - - BEHAT_WEB_HOST=web + - EZP_TEST_REST_HOST + - BEHAT_SELENIUM_HOST + - BEHAT_WEB_HOST From 000575bbeadde222ff3b8f1c3a07285779700d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Wed, 2 Nov 2016 10:23:05 +0100 Subject: [PATCH 05/15] [Travis] Skip downgrading docker, bundled version is 1.12 now --- .travis.yml | 3 --- bin/.travis/trusty/update_docker.sh | 14 +++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index fbd0034945..f23abe9fa1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,6 @@ branches: - master - /^\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 diff --git a/bin/.travis/trusty/update_docker.sh b/bin/.travis/trusty/update_docker.sh index 9d4825827c..2a1aaa81d0 100755 --- a/bin/.travis/trusty/update_docker.sh +++ b/bin/.travis/trusty/update_docker.sh @@ -10,10 +10,10 @@ # 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.8.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 -chmod +x docker-compose -sudo mv docker-compose /usr/local/bin +# VM docker version is now 1.12, no need for this +#DOCKER_COMPOSE_VERSION="1.8.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 +#chmod +x docker-compose +#sudo mv docker-compose /usr/local/bin From 345c7fff04b5909ef14ed6a6273104778b10cbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 7 Nov 2016 13:32:26 +0100 Subject: [PATCH 06/15] [Docker] Use own Varnish image to get latest one and reduce malloc size --- doc/docker-compose/Dockerfile-varnish | 26 ++++++++++++++++++++++++++ doc/docker-compose/varnish.yml | 6 +++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 doc/docker-compose/Dockerfile-varnish diff --git a/doc/docker-compose/Dockerfile-varnish b/doc/docker-compose/Dockerfile-varnish new file mode 100644 index 0000000000..f82f31d6fe --- /dev/null +++ b/doc/docker-compose/Dockerfile-varnish @@ -0,0 +1,26 @@ +#FROM debian:jessie +FROM debian:stretch +# Based on https://hub.docker.com/r/kardasz/varnish/~/dockerfile/ +# stretch is used in order to install varnish-modules withouth having to compile from source + +# links: +# - https://github.com/varnish/varnish-modules/blob/master/docs/vmod_xkey.rst +# - https://wikitech.wikimedia.org/wiki/XKey + +ENV DEBIAN_FRONTEND noninteractive + +RUN \ + apt-get update -q -y && \ +# apt-get install -q -y --force-yes --no-install-recommends apt-transport-https curl ca-certificates + apt-get install -q -y --force-yes --no-install-recommends ca-certificates varnish-modules varnish + +#RUN \ +# curl https://repo.varnish-cache.org/GPG-key.txt | apt-key add - && \ +# echo "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.1" >> /etc/apt/sources.list.d/varnish-cache.list && \ +# apt-get update -q -y && \ +# apt-get install -q -y --force-yes --no-install-recommends varnish + + +EXPOSE 80 6082 + +CMD ["varnishd", "-F", "-a", ":80", "-T", ":6082", "-f", "/etc/varnish/default.vcl", "-s", "malloc,320M"] diff --git a/doc/docker-compose/varnish.yml b/doc/docker-compose/varnish.yml index 69918002e6..36013a90c3 100644 --- a/doc/docker-compose/varnish.yml +++ b/doc/docker-compose/varnish.yml @@ -9,7 +9,11 @@ services: - HTTPCACHE_PURGE_SERVER=http://varnish varnish: - image: kardasz/varnish + build: + context: . + dockerfile: Dockerfile-varnish + image: my_varnish + mem_limit: 448M ports: - "8081:80" depends_on: From 7779e5a6ec149d9eedadce357a7993e60aef33ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 7 Nov 2016 17:56:24 +0100 Subject: [PATCH 07/15] [Travis] More docker info on failure --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f23abe9fa1..5a99827b5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,8 @@ before_script: # 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" +after_failure: docker-compose logs -t --tail="all" + # disable mail notifications notifications: email: false From 5ba084d6625891242cccec20af927c824845bc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 7 Nov 2016 20:04:43 +0100 Subject: [PATCH 08/15] [Travis] switch to beta group to try to get newer Docker version --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5a99827b5a..073426d3e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: required dist: trusty +group: beta language: generic services: From 0eb7512cb47069ef2b22ad145c645c88129ea5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 7 Nov 2016 20:06:54 +0100 Subject: [PATCH 09/15] [Travis] More debug output on failure --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 073426d3e2..4fafd831ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,9 @@ before_script: # 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" -after_failure: docker-compose logs -t --tail="all" +after_failure: + - docker-compose logs -t --tail="all" + - docker-compose ps # disable mail notifications notifications: From 67145bf68783b54bf31f858017ae08694ed19437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 7 Nov 2016 21:13:52 +0100 Subject: [PATCH 10/15] tmp use php image with xdebug for more info of failure (assuming php is the one segfaulting here) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4fafd831ef..46dd03d548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ env: matrix: # Disabled until failures on BDD tests with redis is solved / figured out #- 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=fullJson --tags=~@broken" BEHAT_WEB_HOST="varnish" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.yml:doc/docker-compose/selenium.yml" + - TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" BEHAT_WEB_HOST="varnish" PHP_IMAGE=ezsystems/php:7.0-v1-dev COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.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" From 24fd12ce4d4d04ab7b939bf6350f4d4120c8aaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Tue, 8 Nov 2016 00:23:53 +0100 Subject: [PATCH 11/15] [Travis] Add more debug info and limit varnish more --- .travis.yml | 4 +++- doc/docker-compose/Dockerfile-varnish | 2 +- doc/docker-compose/varnish.yml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 46dd03d548..96639bd2db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,8 +46,10 @@ before_script: 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" - - docker-compose ps + # Will show us what is up, and how long it's been up + - docker ps -s # disable mail notifications notifications: diff --git a/doc/docker-compose/Dockerfile-varnish b/doc/docker-compose/Dockerfile-varnish index f82f31d6fe..496e65f36d 100644 --- a/doc/docker-compose/Dockerfile-varnish +++ b/doc/docker-compose/Dockerfile-varnish @@ -23,4 +23,4 @@ RUN \ EXPOSE 80 6082 -CMD ["varnishd", "-F", "-a", ":80", "-T", ":6082", "-f", "/etc/varnish/default.vcl", "-s", "malloc,320M"] +CMD ["varnishd", "-F", "-a", ":80", "-T", ":6082", "-f", "/etc/varnish/default.vcl", "-s", "malloc,256M"] diff --git a/doc/docker-compose/varnish.yml b/doc/docker-compose/varnish.yml index 36013a90c3..aa6d92999f 100644 --- a/doc/docker-compose/varnish.yml +++ b/doc/docker-compose/varnish.yml @@ -13,7 +13,8 @@ services: context: . dockerfile: Dockerfile-varnish image: my_varnish - mem_limit: 448M + mem_limit: 384M + memswap_limit: 512M ports: - "8081:80" depends_on: From 7cfca120a7edcec7ff5ded27033f31453b74cf7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Tue, 8 Nov 2016 09:16:17 +0100 Subject: [PATCH 12/15] [Docker] Less verbose ouput during builds; hide composer suggests --- Dockerfile | 2 +- doc/docker-compose/install.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe289be495..30dec00898 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN if [ -d .git ]; then echo "ERROR: .dockerignore folders detected, exiting" & # Install and prepare install RUN mkdir -p web/var \ - && composer install --optimize-autoloader --no-progress --no-interaction --prefer-dist \ + && composer install --optimize-autoloader --no-progress --no-interaction --no-suggest --prefer-dist \ # Clear cache again so env variables are taken into account on startup && rm -Rf app/logs/* app/cache/*/* \ # Fix permissions for www-data diff --git a/doc/docker-compose/install.yml b/doc/docker-compose/install.yml index 1b4d1efbaf..70cb986d95 100644 --- a/doc/docker-compose/install.yml +++ b/doc/docker-compose/install.yml @@ -30,7 +30,7 @@ services: # Second chown line: For dev and behat tests we give a bit extra rights, never do this for prod. command: > /bin/sh -c " - composer install --no-progress --no-interaction --prefer-dist; + composer install --no-progress --no-interaction --no-suggest --prefer-dist; mkdir -p web/var; php /scripts/wait_for_db.php; php app/console ezplatform:install ${INSTALL_EZ_INSTALL_TYPE}; From 757f3098c31b8a533ad88ec002190de9dec25ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Tue, 8 Nov 2016 09:16:50 +0100 Subject: [PATCH 13/15] tmp run behat using phpdb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 96639bd2db..3c35e5e95b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ before_script: # 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" +script: docker-compose exec --privileged --user www-data app sh -c "php /scripts/wait_for_db.php; phpdbg -rr $TEST_CMD" after_failure: # Will show us the full log of container's main processes (not counting shell process above running php and behat) From fe512af1df22620be2043dc2d063958ee216442e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Tue, 8 Nov 2016 09:38:11 +0100 Subject: [PATCH 14/15] tmp attempt to run via gdb --- .travis.yml | 12 ++++++------ Dockerfile | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c35e5e95b..a869be05b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,11 @@ env: matrix: # Disabled until failures on BDD tests with redis is solved / figured out #- 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=fullJson --tags=~@broken" BEHAT_WEB_HOST="varnish" PHP_IMAGE=ezsystems/php:7.0-v1-dev COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.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" - - TEST_CMD="bin/behat -vv --profile=platformui --tags='@common'" + - TEST_CMD="bin/behat -vv --profile=rest --suite=fullJson --tags=~@broken" BEHAT_WEB_HOST="varnish" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/varnish.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" + # - TEST_CMD="bin/behat -vv --profile=platformui --tags='@common'" # test only master (+ Pull requests) branches: @@ -43,7 +43,7 @@ before_script: # 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 --privileged --user www-data app sh -c "php /scripts/wait_for_db.php; phpdbg -rr $TEST_CMD" +script: docker-compose exec --privileged --user www-data app sh -c "php /scripts/wait_for_db.php; gdb --args php -e $TEST_CMD" after_failure: # Will show us the full log of container's main processes (not counting shell process above running php and behat) diff --git a/Dockerfile b/Dockerfile index 30dec00898..8caa011a7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ezsystems/php:7.0-v1 +FROM ezsystems/php:7.0-v1-dev # Build argument about keeping auth.json or not (by default on as prod images should'nt get updates via composer update) ARG REMOVE_AUTH=1 From 974a397e10a2a29d92c1d08fccf5243561151aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Wed, 9 Nov 2016 12:45:47 +0100 Subject: [PATCH 15/15] tmp try to debug using xdebug trace --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a869be05b5..3eeb535b3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,13 +43,14 @@ before_script: # 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 --privileged --user www-data app sh -c "php /scripts/wait_for_db.php; gdb --args php -e $TEST_CMD" +script: docker-compose exec --user www-data app sh -c "php /scripts/wait_for_db.php; php -d xdebug.auto_trace=ON -d xdebug.trace_output_dir=app/logs/trace/ $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 what is up, and how long it's been up - docker ps -s + - docker-compose exec --user www-data app cat app/logs/trace/* # disable mail notifications notifications: