Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic update #351

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions conf/cmi/purge.logger_channels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ channels:
- 0
- 2
- 3
-
id: purger_varnish_assets
grants:
- 0
- 2
- 3
4 changes: 4 additions & 0 deletions conf/cmi/purge.plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ purgers:
instance_id: varnish_purge_all
plugin_id: varnish
order_index: 3
-
instance_id: assets
plugin_id: varnish
order_index: 4
processors:
-
plugin_id: drush_purge_queue_work
Expand Down
30 changes: 30 additions & 0 deletions conf/cmi/varnish_purger.settings.assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
uuid: 159f14b3-2fac-40e9-ab35-879b124b0748
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: W2iqfgCjeJZBrD986D1BhZ_gCyDeusZz5ahWyiDDLsM
id: assets
name: Assets
invalidationtype: regex
hostname: localhost
port: 6081
path: '/[invalidation:expression]'
request_method: BAN
scheme: http
verify: '1'
headers:
-
field: X-VC-Purge-Method
value: regex
-
field: Host
value: localhost
body: null
body_content_type: null
runtime_measurement: true
timeout: 1.0
connect_timeout: 1.0
cooldown_time: 0.0
max_requests: 100
http_errors: true
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ services:
image: druidfi/varnish:6-drupal
environment:
VARNISH_BACKEND_HOST: "${COMPOSE_PROJECT_NAME}-app"
VARNISH_CACHE_STATIC_FILES: "1"
depends_on:
- app
networks:
Expand Down
96 changes: 57 additions & 39 deletions public/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,6 @@ function drupal_get_env(string|array $variables) : mixed {
}


if ($varnish_host = getenv('DRUPAL_VARNISH_HOST')) {
$config['varnish_purger.settings.default']['hostname'] = $varnish_host;
$config['varnish_purger.settings.varnish_purge_all']['hostname'] = $varnish_host;

if (!isset($config['system.performance']['cache']['page']['max_age'])) {
$config['system.performance']['cache']['page']['max_age'] = 86400;
}
}

if ($varnish_port = getenv('DRUPAL_VARNISH_PORT')) {
$config['varnish_purger.settings.default']['port'] = $varnish_port;
$config['varnish_purger.settings.varnish_purge_all']['port'] = $varnish_port;
}

if ($navigation_authentication_key = getenv('DRUPAL_NAVIGATION_API_KEY')) {
$config['helfi_navigation.api']['key'] = $navigation_authentication_key;
}
Expand All @@ -182,34 +168,66 @@ function drupal_get_env(string|array $variables) : mixed {
$config['helfi_api_base.environment_resolver.settings']['environment_name'] = getenv('APP_ENV');
$config['helfi_api_base.environment_resolver.settings']['project_name'] = getenv('PROJECT_NAME');

// settings.php doesn't know about existing configuration yet so we can't
// just append new headers to an already existing headers array here.
// If you have configured any extra headers in your purge settings
// you must add them in your all.settings.php as well.
// @todo Replace this with config override service?
$config['varnish_purger.settings.default']['headers'] = [
[
'field' => 'Cache-Tags',
'value' => '[invalidation:expression]',
],
];
if ($varnish_host = getenv('DRUPAL_VARNISH_HOST')) {
// Cache everything for 1 year by default.
$config['system.performance']['cache']['page']['max_age'] = 31536000;

$config['varnish_purger.settings.varnish_purge_all']['headers'] = [
[
'field' => 'X-VC-Purge-Method',
'value' => 'regex',
],
];
$varnish_backend = parse_url($drush_options_uri, PHP_URL_HOST);

if ($varnish_purge_key = getenv('VARNISH_PURGE_KEY')) {
$config['varnish_purger.settings.default']['headers'][] = [
'field' => 'X-VC-Purge-Key',
'value' => $varnish_purge_key,
];
$config['varnish_purger.settings.varnish_purge_all']['headers'][] = [
'field' => 'X-VC-Purge-Key',
'value' => $varnish_purge_key,
if (getenv('APP_ENV') === 'local') {
// Varnish backend is something like varnish-helfi-kymp.docker.so on
// local env.
$varnish_backend = 'varnish-' . $varnish_backend;
}

// settings.php doesn't know about existing configuration yet so we can't
// just append new headers to an already existing headers array here.
// If you have configured any extra headers in your purge settings
// you must add them in your all.settings.php as well.
// @todo Replace this with config override service?
$varnishConfiguration = [
'default' => [
[
'field' => 'Cache-Tags',
'value' => '[invalidation:expression]',
],
],
'assets' => [
[
'field' => 'X-VC-Purge-Method',
'value' => 'regex',
],
[
'field' => 'Host',
'value' => $varnish_backend,
],
],
'varnish_purge_all' => [
[
'field' => 'X-VC-Purge-Method',
'value' => 'regex',
],
],
];

foreach ($varnishConfiguration as $name => $headers) {
$config['varnish_purger.settings.' . $name]['hostname'] = $varnish_host;

if ($varnish_port = getenv('DRUPAL_VARNISH_PORT')) {
$config['varnish_purger.settings.' . $name]['port'] = $varnish_port;
}

foreach ($headers as $header) {
$config['varnish_purger.settings.' . $name]['headers'][] = $header;
}

if ($varnish_purge_key = getenv('VARNISH_PURGE_KEY')) {
$config['varnish_purger.settings.' . $name]['headers'][] = [
'field' => 'X-VC-Purge-Key',
'value' => $varnish_purge_key,
];
}
}
}

if ($stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN')) {
Expand Down