From bee4062714a337d5d9ac52992956dd8f04512e9b Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 22 Sep 2022 18:10:48 -0500 Subject: [PATCH 1/3] Remove Travis stuff (#99) --- .travis.yml | 99 ------------------------------------- tests/travis/functional.sh | 22 --------- tests/travis/images.sh | 41 --------------- tests/travis/static-unit.sh | 12 ----- travis.php.ini | 1 - 5 files changed, 175 deletions(-) delete mode 100644 .travis.yml delete mode 100755 tests/travis/functional.sh delete mode 100755 tests/travis/images.sh delete mode 100755 tests/travis/static-unit.sh delete mode 100644 travis.php.ini diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2c0c491b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,99 +0,0 @@ -os: linux -dist: bionic - -git: - depth: false - -addons: - hosts: - - magento2.docker - - magento2.test - -services: - - docker - -language: php - -stages: - - static-unit - - integration - - build-images - - test - -jobs: - include: - - stage: static-unit - php: '7.2' - script: ./tests/travis/static-unit.sh; - env: - - TEST_SUITE=static-unit - - script: ./tests/travis/static-unit.sh; - php: '7.3' - env: - - TEST_SUITE=static-unit - - script: ./tests/travis/static-unit.sh; - php: '7.4' - env: - - TEST_SUITE=static-unit - - stage: integration - script: ./vendor/bin/phpunit --configuration ./tests/integration; - php: '7.2' - env: - - TEST_SUITE=integration - - script: ./vendor/bin/phpunit --configuration ./tests/integration; - php: '7.3' - env: - - TEST_SUITE=integration - - script: ./vendor/bin/phpunit --configuration ./tests/integration; - php: '7.4' - env: - - TEST_SUITE=integration - - stage: build-images - env: - - TEST_SUITE=build-images - script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh varnish; fi; - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh elasticsearch; fi; - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh nginx; fi; - - script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.2-cli; fi; - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.2-fpm; fi; - env: - - TEST_SUITE=build-images - - script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.3-cli; fi; - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.3-fpm; fi; - env: - - TEST_SUITE=build-images - - script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.4-cli; fi; - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/images.sh php 7.4-fpm; fi; - env: - - TEST_SUITE=build-images - - stage: test - php: '7.2' - dist: xenial - env: - - TEST_SUITE=functional - - php: '7.3' - env: - - TEST_SUITE=functional - - php: '7.4' - env: - - TEST_SUITE=functional - -before_install: - # https://github.com/kylekatarnls/update-helper/issues/9 - - if [ -n "${COMPOSER_VERSION}" ]; then travis_retry composer self-update ${COMPOSER_VERSION}; fi; - -install: - - phpenv config-add travis.php.ini - - if [[ $TEST_SUITE != "build-images" ]]; then composer update; fi; - -before_script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && ([ $TEST_SUITE == "build-images" ] || [ $TEST_SUITE == "functional" ]); then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; fi; - - if [ $TEST_SUITE == "functional" ]; then sudo sysctl -w vm.max_map_count=262144; fi; - - if [ $TEST_SUITE == "functional" ]; then cp codeception.dist.yml codeception.yml && sed -i "s/use_custom_images:\ false/use_custom_images:\ true/" codeception.yml; fi; - -script: - - if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi; diff --git a/tests/travis/functional.sh b/tests/travis/functional.sh deleted file mode 100755 index e171c885..00000000 --- a/tests/travis/functional.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Copyright © Magento, Inc. All rights reserved. -# See COPYING.txt for license details. - -set -e -trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR - -case $TRAVIS_PHP_VERSION in - 7.1) - ./vendor/bin/codecept run -g php71 --steps - ;; - 7.2) - ./vendor/bin/codecept run -g php72 --steps - ;; - 7.3) - ./vendor/bin/codecept run -g php73 --steps - ;; - 7.4) - ./vendor/bin/codecept run -g php74 --steps - ;; -esac diff --git a/tests/travis/images.sh b/tests/travis/images.sh deleted file mode 100755 index 3d588292..00000000 --- a/tests/travis/images.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Copyright © Magento, Inc. All rights reserved. -# See COPYING.txt for license details. - -set -e -trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR - -function build_push_image() { - image_name="$1:$2" - docker build -t "$image_name" "$3" - docker push "$image_name" -} - -function run() { - service_name="$1" - service_version="$2" - - if [[ "$service_version" != "" ]]; then - build_push_image "cloudft/magento-cloud-docker-$service_name" "$service_version-$TRAVIS_BUILD_NUMBER" "./images/$service_name/$service_version" - else - latest_version="" - for service_version in $(ls -1 "./images/$service_name" | sort --version-sort) - do - if [[ $service_version == "cli" ]] || [[ $service_version == "fpm" ]] || [[ $service_version == "es" ]]; then continue; fi; - build_push_image "cloudft/magento-cloud-docker-$service_name" "$service_version-$TRAVIS_BUILD_NUMBER" "./images/$service_name/$service_version" - latest_version="$service_version" - done - - if [[ $service_name != "elasticsearch" ]] && [[ $service_name != "php" ]] && [[ $latest_version != "" ]]; then - build_push_image "cloudft/magento-cloud-docker-$service_name" "$latest_version-$TRAVIS_BUILD_NUMBER" "./images/$service_name/$latest_version" - fi - fi -} - -if [[ $# -gt 0 ]]; then - run $1 $2 -else - echo "Your command line contains no arguments" - exit 1 -fi diff --git a/tests/travis/static-unit.sh b/tests/travis/static-unit.sh deleted file mode 100755 index 07225b56..00000000 --- a/tests/travis/static-unit.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Copyright © Magento, Inc. All rights reserved. -# See COPYING.txt for license details. - -set -e -trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR - -./vendor/bin/phpstan analyse -c ./tests/static/phpstan.neon -./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n -./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml -./vendor/bin/phpunit --configuration ./tests/unit diff --git a/travis.php.ini b/travis.php.ini deleted file mode 100644 index 0b134267..00000000 --- a/travis.php.ini +++ /dev/null @@ -1 +0,0 @@ -memory_limit = 4G From 408004fef11a83efca71f8de122c1210b2306f11 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Sat, 22 Oct 2022 20:53:14 -0500 Subject: [PATCH 2/3] MCLOUD-7879 and MCLOUD-9319: Add Varnish images 6.5, 7.0 and 7.1 (#100) --- images/php/7.2-cli/Dockerfile | 2 +- images/php/7.2-fpm/Dockerfile | 2 +- images/varnish/6.5/Dockerfile | 3 + images/varnish/6.5/etc/default.vcl | 177 ++++++++++++++++++++++++++ images/varnish/7.0/Dockerfile | 3 + images/varnish/7.0/etc/default.vcl | 177 ++++++++++++++++++++++++++ images/varnish/7.1/Dockerfile | 3 + images/varnish/7.1/etc/default.vcl | 177 ++++++++++++++++++++++++++ src/Compose/Php/ExtensionResolver.php | 6 +- 9 files changed, 547 insertions(+), 3 deletions(-) create mode 100755 images/varnish/6.5/Dockerfile create mode 100755 images/varnish/6.5/etc/default.vcl create mode 100755 images/varnish/7.0/Dockerfile create mode 100755 images/varnish/7.0/etc/default.vcl create mode 100755 images/varnish/7.1/Dockerfile create mode 100755 images/varnish/7.1/etc/default.vcl diff --git a/images/php/7.2-cli/Dockerfile b/images/php/7.2-cli/Dockerfile index 328508ca..d474c800 100644 --- a/images/php/7.2-cli/Dockerfile +++ b/images/php/7.2-cli/Dockerfile @@ -136,7 +136,7 @@ RUN pecl install -o -f \ gnupg \ igbinary \ imagick \ - mailparse \ + mailparse-3.1.3 \ msgpack \ oauth \ pcov \ diff --git a/images/php/7.2-fpm/Dockerfile b/images/php/7.2-fpm/Dockerfile index 3afd18e6..e0ee3cbd 100644 --- a/images/php/7.2-fpm/Dockerfile +++ b/images/php/7.2-fpm/Dockerfile @@ -111,7 +111,7 @@ RUN pecl install -o -f \ gnupg \ igbinary \ imagick \ - mailparse \ + mailparse-3.1.3 \ msgpack \ oauth \ pcov \ diff --git a/images/varnish/6.5/Dockerfile b/images/varnish/6.5/Dockerfile new file mode 100755 index 00000000..8f7fbb1d --- /dev/null +++ b/images/varnish/6.5/Dockerfile @@ -0,0 +1,3 @@ +FROM varnish:6.5 + +COPY etc/default.vcl /etc/varnish/ diff --git a/images/varnish/6.5/etc/default.vcl b/images/varnish/6.5/etc/default.vcl new file mode 100755 index 00000000..d9a17a55 --- /dev/null +++ b/images/varnish/6.5/etc/default.vcl @@ -0,0 +1,177 @@ +vcl 4.0; + +import std; + +# The minimal Varnish version is 4.0 +# For SSL offloading, pass the following header in your proxy server or load balancer: 'SSL-OFFLOADED: https' + +backend default { + .host = "web"; + .port = "8080"; + .first_byte_timeout = 300s; + .between_bytes_timeout = 300s; +} + +sub vcl_recv { + # Ensure the true IP is sent onwards. + # This was an issue getting xdebug working through varnish + # whilst having a proxy infront of varnish (for local docker dev) + if (req.http.X-Real-Ip) { + set req.http.X-Forwarded-For = req.http.X-Real-Ip; + } + + if (req.method == "PURGE") { + if (!req.http.X-Magento-Tags-Pattern) { + return (synth(400, "X-Magento-Tags-Pattern header required")); + } + ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern); + return (synth(200, "Purged")); + } + + # Bypass debug session + if (req.http.Cookie ~ "(^|;\s*)(XDEBUG_SESSION=.*)(;|$)") { + return (pass); + } + + if (req.method != "GET" && + req.method != "HEAD" && + req.method != "PUT" && + req.method != "POST" && + req.method != "TRACE" && + req.method != "OPTIONS" && + req.method != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # We only deal with GET and HEAD by default + if (req.method != "GET" && req.method != "HEAD") { + return (pass); + } + + # Bypass shopping cart, checkout and search requests + if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") { + return (pass); + } + + # normalize url in case of leading HTTP scheme and domain + set req.url = regsub(req.url, "^http[s]?://", ""); + + # collect all cookies + std.collect(req.http.Cookie); + + # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression + if (req.http.Accept-Encoding) { + if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { + # No point in compressing these + unset req.http.Accept-Encoding; + } elsif (req.http.Accept-Encoding ~ "gzip") { + set req.http.Accept-Encoding = "gzip"; + } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") { + set req.http.Accept-Encoding = "deflate"; + } else { + # unkown algorithm + unset req.http.Accept-Encoding; + } + } + + # Remove Google gclid parameters to minimize the cache objects + set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA" + set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar" + set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz" + + # static files are always cacheable. remove SSL flag and cookie + if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") { + unset req.http.Https; + unset req.http.SSL-OFFLOADED; + unset req.http.Cookie; + } + + return (hash); +} + +sub vcl_hash { + if (req.http.cookie ~ "X-Magento-Vary=") { + hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1")); + } + + # For multi site configurations to not cache each other's content + if (req.http.host) { + hash_data(req.http.host); + } else { + hash_data(server.ip); + } + + # To make sure http users don't see ssl warning + if (req.http.SSL-OFFLOADED) { + hash_data(req.http.SSL-OFFLOADED); + } + + # Cache https seperately + if (req.http.X-Forwarded-Proto) { + hash_data(req.http.X-Forwarded-Proto); + } +} + +sub vcl_backend_response { + if (beresp.http.content-type ~ "text") { + set beresp.do_esi = true; + } + + if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") { + set beresp.do_gzip = true; + } + + # cache only successfully responses and 404s + if (beresp.status != 200 && beresp.status != 404) { + set beresp.ttl = 0s; + set beresp.uncacheable = true; + return (deliver); + } elsif (beresp.http.Cache-Control ~ "private") { + set beresp.uncacheable = true; + set beresp.ttl = 86400s; + return (deliver); + } + + if (beresp.http.X-Magento-Debug) { + set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control; + } + + # validate if we need to cache it and prevent from setting cookie + # images, css and js are cacheable by default so we have to remove cookie also + if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) { + unset beresp.http.set-cookie; + if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") { + set beresp.http.Pragma = "no-cache"; + set beresp.http.Expires = "-1"; + set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; + set beresp.grace = 1m; + } + } + + # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass + if (beresp.ttl <= 0s || + beresp.http.Surrogate-control ~ "no-store" || + (!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) { + # Mark as Hit-For-Pass for the next 2 minutes + set beresp.ttl = 120s; + set beresp.uncacheable = true; + } + return (deliver); +} + +sub vcl_deliver { + if (resp.http.x-varnish ~ " ") { + set resp.http.X-Magento-Cache-Debug = "HIT"; + } else { + set resp.http.X-Magento-Cache-Debug = "MISS"; + } + + unset resp.http.X-Magento-Debug; + unset resp.http.X-Magento-Tags; + unset resp.http.X-Powered-By; + unset resp.http.Server; + unset resp.http.X-Varnish; + unset resp.http.Via; + unset resp.http.Link; +} diff --git a/images/varnish/7.0/Dockerfile b/images/varnish/7.0/Dockerfile new file mode 100755 index 00000000..9734bc5a --- /dev/null +++ b/images/varnish/7.0/Dockerfile @@ -0,0 +1,3 @@ +FROM varnish:7.0 + +COPY etc/default.vcl /etc/varnish/ diff --git a/images/varnish/7.0/etc/default.vcl b/images/varnish/7.0/etc/default.vcl new file mode 100755 index 00000000..d9a17a55 --- /dev/null +++ b/images/varnish/7.0/etc/default.vcl @@ -0,0 +1,177 @@ +vcl 4.0; + +import std; + +# The minimal Varnish version is 4.0 +# For SSL offloading, pass the following header in your proxy server or load balancer: 'SSL-OFFLOADED: https' + +backend default { + .host = "web"; + .port = "8080"; + .first_byte_timeout = 300s; + .between_bytes_timeout = 300s; +} + +sub vcl_recv { + # Ensure the true IP is sent onwards. + # This was an issue getting xdebug working through varnish + # whilst having a proxy infront of varnish (for local docker dev) + if (req.http.X-Real-Ip) { + set req.http.X-Forwarded-For = req.http.X-Real-Ip; + } + + if (req.method == "PURGE") { + if (!req.http.X-Magento-Tags-Pattern) { + return (synth(400, "X-Magento-Tags-Pattern header required")); + } + ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern); + return (synth(200, "Purged")); + } + + # Bypass debug session + if (req.http.Cookie ~ "(^|;\s*)(XDEBUG_SESSION=.*)(;|$)") { + return (pass); + } + + if (req.method != "GET" && + req.method != "HEAD" && + req.method != "PUT" && + req.method != "POST" && + req.method != "TRACE" && + req.method != "OPTIONS" && + req.method != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # We only deal with GET and HEAD by default + if (req.method != "GET" && req.method != "HEAD") { + return (pass); + } + + # Bypass shopping cart, checkout and search requests + if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") { + return (pass); + } + + # normalize url in case of leading HTTP scheme and domain + set req.url = regsub(req.url, "^http[s]?://", ""); + + # collect all cookies + std.collect(req.http.Cookie); + + # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression + if (req.http.Accept-Encoding) { + if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { + # No point in compressing these + unset req.http.Accept-Encoding; + } elsif (req.http.Accept-Encoding ~ "gzip") { + set req.http.Accept-Encoding = "gzip"; + } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") { + set req.http.Accept-Encoding = "deflate"; + } else { + # unkown algorithm + unset req.http.Accept-Encoding; + } + } + + # Remove Google gclid parameters to minimize the cache objects + set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA" + set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar" + set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz" + + # static files are always cacheable. remove SSL flag and cookie + if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") { + unset req.http.Https; + unset req.http.SSL-OFFLOADED; + unset req.http.Cookie; + } + + return (hash); +} + +sub vcl_hash { + if (req.http.cookie ~ "X-Magento-Vary=") { + hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1")); + } + + # For multi site configurations to not cache each other's content + if (req.http.host) { + hash_data(req.http.host); + } else { + hash_data(server.ip); + } + + # To make sure http users don't see ssl warning + if (req.http.SSL-OFFLOADED) { + hash_data(req.http.SSL-OFFLOADED); + } + + # Cache https seperately + if (req.http.X-Forwarded-Proto) { + hash_data(req.http.X-Forwarded-Proto); + } +} + +sub vcl_backend_response { + if (beresp.http.content-type ~ "text") { + set beresp.do_esi = true; + } + + if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") { + set beresp.do_gzip = true; + } + + # cache only successfully responses and 404s + if (beresp.status != 200 && beresp.status != 404) { + set beresp.ttl = 0s; + set beresp.uncacheable = true; + return (deliver); + } elsif (beresp.http.Cache-Control ~ "private") { + set beresp.uncacheable = true; + set beresp.ttl = 86400s; + return (deliver); + } + + if (beresp.http.X-Magento-Debug) { + set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control; + } + + # validate if we need to cache it and prevent from setting cookie + # images, css and js are cacheable by default so we have to remove cookie also + if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) { + unset beresp.http.set-cookie; + if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") { + set beresp.http.Pragma = "no-cache"; + set beresp.http.Expires = "-1"; + set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; + set beresp.grace = 1m; + } + } + + # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass + if (beresp.ttl <= 0s || + beresp.http.Surrogate-control ~ "no-store" || + (!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) { + # Mark as Hit-For-Pass for the next 2 minutes + set beresp.ttl = 120s; + set beresp.uncacheable = true; + } + return (deliver); +} + +sub vcl_deliver { + if (resp.http.x-varnish ~ " ") { + set resp.http.X-Magento-Cache-Debug = "HIT"; + } else { + set resp.http.X-Magento-Cache-Debug = "MISS"; + } + + unset resp.http.X-Magento-Debug; + unset resp.http.X-Magento-Tags; + unset resp.http.X-Powered-By; + unset resp.http.Server; + unset resp.http.X-Varnish; + unset resp.http.Via; + unset resp.http.Link; +} diff --git a/images/varnish/7.1/Dockerfile b/images/varnish/7.1/Dockerfile new file mode 100755 index 00000000..19b17454 --- /dev/null +++ b/images/varnish/7.1/Dockerfile @@ -0,0 +1,3 @@ +FROM varnish:7.1 + +COPY etc/default.vcl /etc/varnish/ diff --git a/images/varnish/7.1/etc/default.vcl b/images/varnish/7.1/etc/default.vcl new file mode 100755 index 00000000..d9a17a55 --- /dev/null +++ b/images/varnish/7.1/etc/default.vcl @@ -0,0 +1,177 @@ +vcl 4.0; + +import std; + +# The minimal Varnish version is 4.0 +# For SSL offloading, pass the following header in your proxy server or load balancer: 'SSL-OFFLOADED: https' + +backend default { + .host = "web"; + .port = "8080"; + .first_byte_timeout = 300s; + .between_bytes_timeout = 300s; +} + +sub vcl_recv { + # Ensure the true IP is sent onwards. + # This was an issue getting xdebug working through varnish + # whilst having a proxy infront of varnish (for local docker dev) + if (req.http.X-Real-Ip) { + set req.http.X-Forwarded-For = req.http.X-Real-Ip; + } + + if (req.method == "PURGE") { + if (!req.http.X-Magento-Tags-Pattern) { + return (synth(400, "X-Magento-Tags-Pattern header required")); + } + ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern); + return (synth(200, "Purged")); + } + + # Bypass debug session + if (req.http.Cookie ~ "(^|;\s*)(XDEBUG_SESSION=.*)(;|$)") { + return (pass); + } + + if (req.method != "GET" && + req.method != "HEAD" && + req.method != "PUT" && + req.method != "POST" && + req.method != "TRACE" && + req.method != "OPTIONS" && + req.method != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # We only deal with GET and HEAD by default + if (req.method != "GET" && req.method != "HEAD") { + return (pass); + } + + # Bypass shopping cart, checkout and search requests + if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") { + return (pass); + } + + # normalize url in case of leading HTTP scheme and domain + set req.url = regsub(req.url, "^http[s]?://", ""); + + # collect all cookies + std.collect(req.http.Cookie); + + # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression + if (req.http.Accept-Encoding) { + if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { + # No point in compressing these + unset req.http.Accept-Encoding; + } elsif (req.http.Accept-Encoding ~ "gzip") { + set req.http.Accept-Encoding = "gzip"; + } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") { + set req.http.Accept-Encoding = "deflate"; + } else { + # unkown algorithm + unset req.http.Accept-Encoding; + } + } + + # Remove Google gclid parameters to minimize the cache objects + set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA" + set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar" + set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz" + + # static files are always cacheable. remove SSL flag and cookie + if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") { + unset req.http.Https; + unset req.http.SSL-OFFLOADED; + unset req.http.Cookie; + } + + return (hash); +} + +sub vcl_hash { + if (req.http.cookie ~ "X-Magento-Vary=") { + hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1")); + } + + # For multi site configurations to not cache each other's content + if (req.http.host) { + hash_data(req.http.host); + } else { + hash_data(server.ip); + } + + # To make sure http users don't see ssl warning + if (req.http.SSL-OFFLOADED) { + hash_data(req.http.SSL-OFFLOADED); + } + + # Cache https seperately + if (req.http.X-Forwarded-Proto) { + hash_data(req.http.X-Forwarded-Proto); + } +} + +sub vcl_backend_response { + if (beresp.http.content-type ~ "text") { + set beresp.do_esi = true; + } + + if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") { + set beresp.do_gzip = true; + } + + # cache only successfully responses and 404s + if (beresp.status != 200 && beresp.status != 404) { + set beresp.ttl = 0s; + set beresp.uncacheable = true; + return (deliver); + } elsif (beresp.http.Cache-Control ~ "private") { + set beresp.uncacheable = true; + set beresp.ttl = 86400s; + return (deliver); + } + + if (beresp.http.X-Magento-Debug) { + set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control; + } + + # validate if we need to cache it and prevent from setting cookie + # images, css and js are cacheable by default so we have to remove cookie also + if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) { + unset beresp.http.set-cookie; + if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") { + set beresp.http.Pragma = "no-cache"; + set beresp.http.Expires = "-1"; + set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; + set beresp.grace = 1m; + } + } + + # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass + if (beresp.ttl <= 0s || + beresp.http.Surrogate-control ~ "no-store" || + (!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) { + # Mark as Hit-For-Pass for the next 2 minutes + set beresp.ttl = 120s; + set beresp.uncacheable = true; + } + return (deliver); +} + +sub vcl_deliver { + if (resp.http.x-varnish ~ " ") { + set resp.http.X-Magento-Cache-Debug = "HIT"; + } else { + set resp.http.X-Magento-Cache-Debug = "MISS"; + } + + unset resp.http.X-Magento-Debug; + unset resp.http.X-Magento-Tags; + unset resp.http.X-Powered-By; + unset resp.http.Server; + unset resp.http.X-Varnish; + unset resp.http.Via; + unset resp.http.Link; +} diff --git a/src/Compose/Php/ExtensionResolver.php b/src/Compose/Php/ExtensionResolver.php index d5ddef93..c00f9198 100644 --- a/src/Compose/Php/ExtensionResolver.php +++ b/src/Compose/Php/ExtensionResolver.php @@ -272,7 +272,11 @@ public static function getConfig(): array ], ], 'mailparse' => [ - '>=7.0' => [self::EXTENSION_TYPE => self::EXTENSION_TYPE_PECL], + '<7.3' => [ + self::EXTENSION_TYPE => self::EXTENSION_TYPE_PECL, + self::EXTENSION_PACKAGE_NAME => 'mailparse-3.1.3', + ], + '>=7.3' => [self::EXTENSION_TYPE => self::EXTENSION_TYPE_PECL], ], 'mcrypt' => [ '>=7.0.0 <7.2' => [ From 05732b0a557348bef38d98d3c7d98ff6888c1c39 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Mon, 24 Oct 2022 15:15:15 -0500 Subject: [PATCH 3/3] Bump MCD version - 1.3.4 (#101) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 88d08e6d..bdee8976 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento-cloud-docker", "description": "Magento Cloud Docker", "type": "magento2-component", - "version": "1.3.3", + "version": "1.3.4", "license": [ "OSL-3.0", "AFL-3.0"