Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Merge branch '1.13' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Feb 15, 2018
2 parents df33cee + f107019 commit c356c09
Show file tree
Hide file tree
Showing 20 changed files with 279 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -44,6 +44,7 @@
/web/index_cluster.php

/doc/docker/entrypoint/*/*.sql
/dfsdata

/web/css/
/web/js/
Expand Down
42 changes: 32 additions & 10 deletions .platform.app.yaml
Expand Up @@ -18,12 +18,26 @@ build:
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
database: 'mysqldb:mysql'
database: 'mysqldb:user'
# Uncomment if you want to store dfs tables in a separate database:
#dfs_database: 'mysqldb:dfs'
rediscache: 'rediscache:redis'
# If you wish to have a separate Redis instance for sessions, uncomment
# this relationship and the corresponding service in .platform/services.yaml
#redissession: 'redissession:redis'

variables:
#php:
# Example of setting php.ini config
#"display_errors": "On"
env:
# For enterprise cluster, disable Symfony Proxy & instead use Fastly Bundle available on eZ Platform Enterprise
#SYMFONY_HTTP_CACHE: 0
# Change this to dev if you want to run site & commands in dev
SYMFONY_ENV: prod
# Uncomment if you want to use DFS clustering:
#PLATFORMSH_DFS_NFS_PATH: 'dfsdata'

# The configuration of app when it is exposed to the web.
web:
locations:
Expand All @@ -45,43 +59,51 @@ mounts:
"/web/var": "shared:files/files"
# Might want to not mount this one, it will slow down sessions, if you need cluster use memcached/redis!
"/var/sessions": "shared:files/sessions"
# Uncomment if you want to use DFS clustering:
#"/dfsdata": "shared:files/dfsdata"

# The hooks that will be performed when the package is deployed.
hooks:
# Build hook, done once before connected to services, disk is still writable here
build: |
set -e
rm web/app_dev.php
. ./.env
if [ -z "$SYMFONY_ENV" ]; then
export SYMFONY_ENV=prod
fi
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 on each server (if cluster), only mounts are writable at this point
deploy: |
set -e
. ./.env
if [ -z "$SYMFONY_ENV" ]; then
export SYMFONY_ENV=prod
fi
if [ ! -f web/var/.platform.installed ]; then
php -d memory_limit=-1 bin/console ezplatform:install --env=$SYMFONY_ENV $INSTALL_EZ_INSTALL_TYPE
php -d memory_limit=-1 bin/console ezplatform:install $INSTALL_EZ_INSTALL_TYPE
touch web/var/.platform.installed
fi
bin/console --env=$SYMFONY_ENV cache:clear
# As we are deploying code changes we need to clear any kind of code/system cache
rm -f app/cache/*/*
bin/console cache:clear
# Example of addtional deploy hooks if you use doctrine and/or kaliop migration bundle
##bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
##bin/console kaliop:migration:migrate --no-interaction --no-debug
# The configuration of scheduled execution.
# see http://symfony.com/doc/current/components/console/introduction.html
#crons:
# symfony:
# spec: "*/20 * * * *"
# cmd: "php cron.php example:test"
# cmd: "php app/console ezpublish:cron:run"

runtime:
extensions:
- xsl
- imagick
- readline
- redis
#- apcu
#- name: 'blackfire'
# configuration:
# server_id: 'xxxx-xxx-xxx-xxx-xxxx'
# server_token: 'xxxx'
17 changes: 16 additions & 1 deletion .platform/services.yaml
@@ -1,6 +1,21 @@
mysqldb:
type: mysql:10.0
type: mysql:10.1
disk: 2048
configuration:
schemas:
- main
# Uncomment if you want to store dfs tables in a separate database:
#- dfs
endpoints:
user:
default_schema: main
privileges:
main: admin
# Uncomment if you want to store dfs tables in a separate database:
#dfs:
# default_schema: dfs
# privileges:
# dfs: admin

# For use by Symfony Cache (used by eZ Platform SPI Persistence Cache)
rediscache:
Expand Down
2 changes: 1 addition & 1 deletion app/config/cache_pool/cache.memcached.yml
@@ -1,4 +1,4 @@
# Reusable service for memcache cache for use in tests/docker/platform.sh
# Reusable service for memcache cache for use in generic.php and plaformsh.php on demand
services:
cache.memcached:
parent: cache.adapter.memcached
Expand Down
2 changes: 1 addition & 1 deletion app/config/cache_pool/cache.redis.yml
@@ -1,4 +1,4 @@
# Reusable service for redis cache for use in tests/docker/platform.sh
# Reusable service for redis cache for use in generic.php and plaformsh.php on demand
services:
cache.redis:
parent: cache.adapter.redis
Expand Down
3 changes: 2 additions & 1 deletion app/config/config.yml
Expand Up @@ -64,7 +64,8 @@ framework:
trusted_hosts: ~
session:
# https://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
# handler_id set to null will use default session handler from php.ini
handler_id: '%ezplatform.session.handler_id%'
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
# Note: eZ Publish also allows session name and session cookie configuration to be per SiteAccess, by
# default session name will be set to "eZSESSID{siteaccess_hash}" (unique session name per siteaccess)
Expand Down
15 changes: 14 additions & 1 deletion app/config/config_prod.yml
Expand Up @@ -2,11 +2,24 @@ imports:
- { resource: config.yml }
- { resource: ezplatform_prod.yml }

# Example below would make sure some of the symfony caches are written to apc / redis instead of disk
# Make sure to verify if cache clearing is done as you expect when doing such changes.

#framework:
# validation:
# cache: validator.mapping.cache.doctrine.apc
# serializer:
# cache: serializer.mapping.cache.apc
#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc
## Result (& the experimental Second level) cache needs to be shared among servers so should use for instance Redis
# result_cache_driver:
# type: redis
# host:
# port:


monolog:
handlers:
Expand Down
1 change: 1 addition & 0 deletions app/config/default_parameters.yml
@@ -1,6 +1,7 @@
# This file contains defaults for optional parameters, which you can override in parameters.yml
parameters:
locale_fallback: en
ezplatform.session.handler_id: session.handler.native_file

# A secret key that's used to generate certain security-related tokens
secret: '%env(SYMFONY_SECRET)%'
Expand Down
38 changes: 38 additions & 0 deletions app/config/dfs/dfs.yml
@@ -0,0 +1,38 @@
# new doctrine connection for the dfs legacy_dfs_cluster metadata handler.
doctrine:
dbal:
connections:
dfs:
driver: "%dfs_database_driver%"
host: "%dfs_database_host%"
port: "%dfs_database_port%"
user: "%dfs_database_user%"
password: "%dfs_database_password%"
dbname: "%dfs_database_name%"
charset: UTF8

# define the flysystem handler
oneup_flysystem:
adapters:
nfs_adapter:
local:
directory: "/%dfs_nfs_path%/$var_dir$/$storage_dir$"

# define the ez handlers
ez_io:
binarydata_handlers:
nfs:
flysystem:
adapter: nfs_adapter
metadata_handlers:
dfs:
legacy_dfs_cluster:
connection: doctrine.dbal.dfs_connection

# set the application handlers
ezpublish:
system:
default:
io:
metadata_handler: dfs
binarydata_handler: nfs
43 changes: 43 additions & 0 deletions app/config/env/generic.php
Expand Up @@ -5,6 +5,49 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader;

if ($dfsNfsPath = getenv('DFS_NFS_PATH')) {
$container->setParameter('dfs_nfs_path', $dfsNfsPath);

if ($value = getenv('DFS_DATABASE_DRIVER')) {
$container->setParameter('dfs_database_driver', $value);
} else {
$container->setParameter('dfs_database_driver', $container->getParameter('database_driver'));
}

if ($value = getenv('DFS_DATABASE_HOST')) {
$container->setParameter('dfs_database_host', $value);
} else {
$container->setParameter('dfs_database_host', $container->getParameter('database_host'));
}

if ($value = getenv('DFS_DATABASE_PORT')) {
$container->setParameter('dfs_database_port', $value);
} else {
$container->setParameter('dfs_database_port', $container->getParameter('database_port'));
}

if ($value = getenv('DFS_DATABASE_NAME')) {
$container->setParameter('dfs_database_name', $value);
} else {
$container->setParameter('dfs_database_name', $container->getParameter('database_name'));
}

if ($value = getenv('DFS_DATABASE_USER')) {
$container->setParameter('dfs_database_user', $value);
} else {
$container->setParameter('dfs_database_user', $container->getParameter('database_user'));
}

if ($value = getenv('DFS_DATABASE_PASSWORD')) {
$container->setParameter('dfs_database_password', $value);
} else {
$container->setParameter('dfs_database_password', $container->getParameter('database_password'));
}

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../dfs'));
$loader->load('dfs.yml');
}

// Cache settings
// If CACHE_POOL env variable is set, check if there is a yml file that needs to be loaded for it
if (($pool = getenv('CACHE_POOL')) && file_exists(__DIR__ . "/../cache_pool/${pool}.yml")) {
Expand Down
56 changes: 48 additions & 8 deletions app/config/env/platformsh.php
@@ -1,5 +1,8 @@
<?php

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader;

$relationships = getenv('PLATFORM_RELATIONSHIPS');
if (!$relationships) {
return;
Expand All @@ -18,21 +21,56 @@
$container->setParameter('database_name', $endpoint['path']);
$container->setParameter('database_user', $endpoint['username']);
$container->setParameter('database_password', $endpoint['password']);
$container->setParameter('database_path', '');

// 'cluster_database_name' is deprecated in eZ Platform 1.13.1/2.1
// Cluster DB name is hardcoded. It will have no any effect if cluster is disabled
$container->setParameter('cluster_database_name', 'cluster');
}

// PLATFORMSH_DFS_NFS_PATH is different compared to DFS_NFS_PATH in the sense that it is relative to ezplatform dir
// DFS_NFS_PATH is an absolute path
if ($dfsNfsPath = getenv('PLATFORMSH_DFS_NFS_PATH')) {
$container->setParameter('dfs_nfs_path', sprintf('%s/%s', dirname($container->getParameter('kernel.root_dir')), $dfsNfsPath));

if (array_key_exists('dfs_database', $relationships)) {
foreach ($relationships['dfs_database'] as $endpoint) {
if (empty($endpoint['query']['is_master'])) {
continue;
}

$container->setParameter('dfs_database_driver', 'pdo_' . $endpoint['scheme']);
$container->setParameter('dfs_database_host', $endpoint['host']);
$container->setParameter('dfs_database_port', $endpoint['port']);
$container->setParameter('dfs_database_name', $endpoint['path']);
$container->setParameter('dfs_database_user', $endpoint['username']);
$container->setParameter('dfs_database_password', $endpoint['password']);
}
} else {
// If dfs_database endpoint is not defined, we'll use the default database for DFS too
$container->setParameter('dfs_database_driver', $container->getParameter('database_driver'));
$container->setParameter('dfs_database_host', $container->getParameter('database_host'));
$container->setParameter('dfs_database_port', $container->getParameter('database_port'));
$container->setParameter('dfs_database_name', $container->getParameter('database_name'));
$container->setParameter('dfs_database_user', $container->getParameter('database_user'));
$container->setParameter('dfs_database_password', $container->getParameter('database_password'));
}

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../dfs'));
$loader->load('dfs.yml');
}
// Use Redis-based caching if possible.
if (isset($relationships['rediscache'])) {
foreach ($relationships['rediscache'] as $endpoint) {
if ($endpoint['scheme'] !== 'redis') {
continue;
}

$container->setParameter('cache_pool', 'singleredis');
$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_redis_port', $endpoint['port']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../cache_pool'));
$loader->load('singleredis.yml');
}
} elseif (isset($relationships['cache'])) {
// Fallback to memcached if here (deprecated, we will only handle redis here in the future)
Expand All @@ -41,8 +79,13 @@
continue;
}

@trigger_error('Usage of Memcached is deprecated, redis is recommended', E_USER_DEPRECATED);

$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_memcached_port', $endpoint['port']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../cache_pool'));
$loader->load('singlememcached.yml');
}
}

Expand All @@ -55,21 +98,18 @@
continue;
}

ini_set('session.save_handler', 'redis');
ini_set('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
$container->setParameter('ezplatform.session.handler_id', 'ezplatform.core.session.handler.native_redis');
$container->setParameter('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
}
} elseif (isset($relationships['rediscache'])) {
foreach ($relationships['redissession'] as $endpoint) {
if ($endpoint['scheme'] !== 'redis') {
continue;
}

ini_set('session.save_handler', 'redis');
ini_set('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
$container->setParameter('ezplatform.session.handler_id', 'ezplatform.core.session.handler.native_redis');
$container->setParameter('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
}
} else {
// Store session into /tmp.
ini_set('session.save_path', '/tmp/sessions');
}

// Disable PHPStormPass
Expand Down

0 comments on commit c356c09

Please sign in to comment.