Skip to content

Commit

Permalink
Merge branch '1.13' into studio_1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Mar 20, 2018
2 parents caf28ea + e1de832 commit 7eeefdc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .platform.app.yaml
Expand Up @@ -76,26 +76,38 @@ hooks:
composer config http-basic.updates.ez.no $COMPOSER_KEY $COMPOSER_PASSWORD
composer install --no-dev --prefer-dist --no-progress --no-interaction --optimize-autoloader
rm web/app_dev.php
. ./.env
if [ "$SYMFONY_ENV" = "dev" ] ; then
composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader
else
composer install --no-dev --prefer-dist --no-progress --no-interaction --optimize-autoloader
fi
# Deploy hook, access to services & done once (per cluster, not per node), only mounts are writable at this point
# Note: Http traffic is paused while this is running, so for prod code this should finish as fast as possible, < 30s
deploy: |
set -e
. ./.env
# Mainly relevant for eZ Platform demo usage, for own setup adapt this or remove and rely on migrations.
if [ ! -f web/var/.platform.installed ]; then
. ./.env
php -d memory_limit=-1 app/console ezplatform:install $INSTALL_EZ_INSTALL_TYPE
touch web/var/.platform.installed
fi
# As we are deploying code changes we need to clear any kind of code/system cache
rm -Rf app/cache/*/*.*
app/console cache:clear
# Example of addtional deploy hooks if you use doctrine and/or kaliop migration bundle
# When deploying changes to existing cluster, clear all cache now that we have shared mounts available
if [ "$SYMFONY_ENV" != "prod" ] ; then
# Clear class cache before we boot up symfony in case of interface changes on classes cached
rm -Rf app/cache/$SYMFONY_ENV/*.*
app/console cache:clear
elif [ -d "app/cache/prod/$PLATFORM_TREE_ID" ] ; then
# Clear cache on re-deploy when the folder exits, move folder so post_deploy can cleanup
mv -f app/cache/prod/$PLATFORM_TREE_ID app/cache/prod/old_deploy
fi
# Example of additional deploy hooks if you use doctrine and/or kaliop migration bundle
##app/console doctrine:migrations:migrate --no-interaction --allow-no-migration
##app/console kaliop:migration:migrate --no-interaction --no-debug
# Post deploy hook, like deploy but after being deployed and live, for deploy tasks we can do asynchronously
post_deploy: |
set -e
# Cleanup old prod cache folders, basically all except current $PLATFORM_TREE_ID folder.
find app/cache/prod -mindepth 1 -maxdepth 1 -type d \! \( -name "$PLATFORM_TREE_ID" \) -exec rm -rf '{}' \;
# The configuration of scheduled execution.
# see http://symfony.com/doc/current/components/console/introduction.html
Expand Down
10 changes: 10 additions & 0 deletions app/AppKernel.php
Expand Up @@ -77,6 +77,16 @@ public function registerBundles()
return $bundles;
}

public function getCacheDir()
{
// On platform.sh place each deployment cache in own folder to rather cleanup old cache async
if ($this->getEnvironment() === 'prod' && ($platformTreeId = getenv('PLATFORM_TREE_ID'))) {
return "{$this->getRootDir()}/cache/{$this->getEnvironment()}/{$platformTreeId}";
}

return parent::getCacheDir();
}

/**
* Loads the container configuration.
*
Expand Down
4 changes: 4 additions & 0 deletions doc/varnish/vcl/varnish3_ban.vcl
Expand Up @@ -14,6 +14,10 @@ sub vcl_recv {
// Advertise Symfony for ESI support
set req.http.Surrogate-Capability = "abc=ESI/1.0";

// Varnish, in its default configuration, sends the X-Forwarded-For header but does not filter out Forwarded header
// To be removed in Symfony 3.3
unset req.http.Forwarded;

// 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") {
Expand Down
11 changes: 11 additions & 0 deletions doc/varnish/vcl/varnish4_ban.vcl
Expand Up @@ -16,6 +16,17 @@ sub vcl_recv {
// Advertise Symfony for ESI support
set req.http.Surrogate-Capability = "abc=ESI/1.0";

// Varnish, in its default configuration, sends the X-Forwarded-For header but does not filter out Forwarded header
// To be removed in Symfony 3.3
unset req.http.Forwarded;

// Ensure that the Symfony Router generates URLs correctly with Varnish
if (req.http.X-Forwarded-Proto == "https" ) {
set req.http.X-Forwarded-Port = "443";
} else {
set req.http.X-Forwarded-Port = "80";
}

// 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") {
Expand Down

0 comments on commit 7eeefdc

Please sign in to comment.