-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings-default.php
160 lines (146 loc) · 7.21 KB
/
settings-default.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
// @codingStandardsIgnoreFile
// Database settings.
$databases['default']['default'] = [
'host' => getenv('dbHost'),
'port' => getenv('dbPort'),
'database' => getenv('dbName'),
'username' => getenv('dbUser'),
'password' => getenv('dbPassword'),
'namespace' => 'Drupal\Core\Database\Driver\mysql',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
];
// Location of the site configuration files.
$settings['config_sync_directory'] = '../config/sync';
// Configure file paths
// Private file paths.
$settings['file_private_path'] = getenv('DRUPAL_SHARED_VOLUME') . '/private';
// Configure tmp folder
// See: https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/600
$settings['file_temp_path'] = '/tmp';
// Configure feeds tmp folder
// Fix: https://www.drupal.org/project/feeds/issues/2912130
if (isset($config['system.file']) && !is_null($config['system.file']['path']['temporary']))
{
$config['system.file']['path']['temporary'] = getenv('DRUPAL_SHARED_VOLUME') . "/private/feeds/tmp";
}
// Config trusted host pattern
$trusted_host_pattern="^". str_replace(".","\.",getenv('HOSTNAME')) . "$";
$settings['trusted_host_patterns'] = [ '.*' ];
// Salt for one-time login links, cancel links, form tokens, etc.
$settings['hash_salt'] = hash("sha256",getenv('dbName') . getenv('dbUser') . getenv('dbPasswordgit'));
/**
* Load services definition file.
*/
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
/**
* The default list of directories that will be ignored by Drupal's file API.
*
* By default ignore node_modules folders to avoid issues
* with common frontend tools and recursive scanning of directories looking for
* extensions.
*
* @see file_scan_directory()
* @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
*/
$settings['file_scan_ignore_directories'] = [
'node_modules',
];
/**
* Redis Configuration.
* @See https://pantheon.io/docs/redis/ > No Keys Found
* @See also https://gist.github.com/keopx/7d5fe4d7a890c792c43bb79cf56718e0
* @ See also https://docs.platform.sh/frameworks/drupal8/redis.html
*/
if (extension_loaded('redis') && (getenv('ENABLE_REDIS') == "true")) {
// Set Redis as the default backend for any cache bin not otherwise specified.
$settings['cache']['default'] = 'cache.backend.redis';
$settings['redis.connection']['interface'] = 'PhpRedis';
//$settings['redis.connection']['host'] = 'redis.' . getenv('NAMESPACE') . '.svc.cluster.local';
$settings['redis.connection']['host'] = getenv('REDIS_SERVICE_HOST');
$settings['redis.connection']['port'] = getenv('REDIS_SERVICE_PORT');
// NOTE: env `REDIS_PASSWORD` needs to be manually exposed
$settings['redis.connection']['password'] = getenv('REDIS_PASSWORD');
// Allow the services to work before the Redis module itself is enabled.
$settings['container_yamls'][] = 'modules/contrib/redis/redis.services.yml';
// Manually add the classloader path, this is required for the container cache bin definition below
// and allows to use it without the redis module being enabled.
$class_loader->addPsr4('Drupal\\redis\\', 'modules/contrib/redis/src');
// Use redis for container cache.
// The container cache is used to load the container definition itself, and
// thus any configuration stored in the container itself is not available
// yet. These lines force the container cache to use Redis rather than the
// default SQL cache.
$settings['bootstrap_container_definition'] = [
'parameters' => [],
'services' => [
'redis.factory' => [
'class' => 'Drupal\redis\ClientFactory',
],
'cache.backend.redis' => [
'class' => 'Drupal\redis\Cache\CacheBackendFactory',
'arguments' => ['@redis.factory', '@cache_tags_provider.container', '@serialization.phpserialize'],
],
'cache.container' => [
'class' => '\Drupal\redis\Cache\PhpRedis',
'factory' => ['@cache.backend.redis', 'get'],
'arguments' => ['container'],
],
'cache_tags_provider.container' => [
'class' => 'Drupal\redis\Cache\RedisCacheTagsChecksum',
'arguments' => ['@redis.factory'],
],
'serialization.phpserialize' => [
'class' => 'Drupal\Component\Serialization\PhpSerialize',
],
],
];
/** Optional prefix for cache entries */
$settings['cache_prefix'] = getenv('NAMESPACE');
/** @see: https://pantheon.io/docs/redis/ */
// Always set the fast backend for bootstrap, discover and config, otherwise
// this gets lost when redis is enabled.
$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['config'] = 'cache.backend.chainedfast';
/** @see: https://github.com/md-systems/redis */
// Use for all bins otherwise specified.
$settings['cache']['default'] = 'cache.backend.redis';
// Use this to only use it for specific cache bins.
$settings['cache']['bins']['render'] = 'cache.backend.redis';
// Use for all queues unless otherwise specified for a specific queue.
$settings['queue_default'] = 'queue.redis';
// Or if you want to use reliable queue implementation.
$settings['queue_default'] = 'queue.redis_reliable';
// Use this to only use Redis for a specific queue (aggregator_feeds in this case).
$settings['queue_service_aggregator_feeds'] = 'queue.redis';
// Or if you want to use reliable queue implementation.
$settings['queue_service_aggregator_feeds'] = 'queue.redis_reliable';
}
/**
* Load local development override configuration, if available.
*
* Use settings.local.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing emails, and
* other things that should not happen on development and testing sites.
*
* Keep this code block at the end of this file to take full effect.
*/
if (getenv('ENVIRONMENT') != 'production' && file_exists($app_root . '/' . $site_path . '/settings.' . getenv('ENVIRONMENT') . '.php')) {
include $app_root . '/' . $site_path . '/settings.' . getenv('ENVIRONMENT') . '.php';
}
// These settings fix https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/271
// with the patch from https://www.drupal.org/project/drupal/issues/2833539#comment-12574515
// See: https://www.drupal.org/project/drupal/issues/1650930
// if ($db_driver === 'mysql') {
// $databases['default']['default']['init_commands']['isolation'] = "SET SESSION tx_isolation='READ-COMMITTED'";
$databases['default']['default']['init_commands']['lock_wait_timeout'] = "SET SESSION innodb_lock_wait_timeout = 20";
$databases['default']['default']['init_commands']['wait_timeout'] = "SET SESSION wait_timeout = 600";
// These settings force HTTPS for all content served by drupal
// See: https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/787
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
$settings['reverse_proxy_trusted_headers'] = \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_FOR | \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PROTO | \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PORT;