Skip to content

Commit 8b9e384

Browse files
aOelschlageralxp
andauthored
Update how settings.php gets appended (#403)
* Updated how settings.php is appended * Fix make starter. * remove other call to update settings and change fedora url --------- Co-authored-by: Alexander O'Neill <[email protected]>
1 parent dc8ed0c commit 8b9e384

File tree

3 files changed

+96
-5
lines changed

3 files changed

+96
-5
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ starter: generate-secrets
159159
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'cd /home/root && composer install'; \
160160
fi
161161
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter
162+
rm ./codebase/assets/patches/default_settings.txt
163+
cp default_settings.txt ./codebase/assets/patches
164+
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter
162165
$(MAKE) compose-up
166+
docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx /var/www/drupal/ ; su nginx -s /bin/bash -c "composer install"'
163167
$(MAKE) starter-finalize ENVIRONMENT=starter
164168

165169

@@ -172,6 +176,9 @@ starter_dev: generate-secrets
172176
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'git clone -b main https://github.com/Islandora-Devops/islandora-starter-site /home/root;'; \
173177
fi
174178
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev
179+
rm ./codebase/assets/patches/default_settings.txt
180+
cp default_settings.txt ./codebase/assets/patches
181+
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev
175182
$(MAKE) compose-up
176183
docker compose exec -T -u nginx drupal sh -c 'composer install'
177184
$(MAKE) starter-finalize ENVIRONMENT=starter_dev
@@ -551,7 +558,7 @@ delete-shortcut-entities:
551558
.PHONY: hydrate
552559
.SILENT: hydrate
553560
## Reconstitute the site from environment variables.
554-
hydrate: update-settings-php update-config-from-environment solr-cores namespaces run-islandora-migrations
561+
hydrate: update-config-from-environment solr-cores namespaces run-islandora-migrations
555562
docker compose exec -T drupal drush cr -y
556563

557564

@@ -576,7 +583,8 @@ starter-init: init
576583
.PHONY: starter-finalize
577584
starter-finalize:
578585
docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx . ; echo "Chown Complete"'
579-
$(MAKE) drupal-database update-settings-php
586+
$(MAKE) drupal-database
587+
580588
docker compose exec -T drupal with-contenv bash -lc "drush si -y --existing-config minimal --account-pass '$(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD)'"
581589
docker compose exec -T drupal with-contenv bash -lc "drush cr"
582590
docker compose exec -T drupal with-contenv bash -lc "drush -l $(SITE) user:role:add fedoraadmin admin"

build/docker-compose/docker-compose.drupal.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ services:
88
drupal:
99
restart: ${RESTART_POLICY:-unless-stopped}
1010
environment:
11+
DRUPAL_DEFAULT_BROKER_URL: tcp://activemq:61613
1112
DRUPAL_DEFAULT_CANTALOUPE_URL: https://${DOMAIN}/cantaloupe/iiif/2
12-
DRUPAL_DEFAULT_FCREPO_HOST: ${DOMAIN}
13-
DRUPAL_DEFAULT_FCREPO_PORT: 8081
14-
DRUPAL_DEFAULT_SITE_URL: http://${DOMAIN} # Make sure this is just http and not https!
13+
DRUPAL_DEFAULT_FCREPO_URL: http://${DOMAIN}:8081/fcrepo/rest/
14+
DRUPAL_DEFAULT_SITE_URL: ${DOMAIN}
1515
DRUPAL_DEFAULT_PROFILE: ${DRUPAL_INSTALL_PROFILE}
1616
PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT}
1717
PHP_POST_MAX_SIZE: ${PHP_POST_MAX_SIZE}

default_settings.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Section appended onto drupal/core default.settings.php via "drupal-scaffold" in composer.json.
3+
*/
4+
5+
// Let Drush use all the memory available.
6+
if (PHP_SAPI === 'cli') {
7+
ini_set('memory_limit', '-1');
8+
}
9+
10+
// Required when running Drupal behind a reverse proxy.
11+
$settings['reverse_proxy'] = TRUE;
12+
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
13+
$settings['reverse_proxy_trusted_headers'] = \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_FOR |
14+
\Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PROTO | \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_PORT;
15+
16+
/**
17+
* Private file path:
18+
*
19+
* A local file system path where private files will be stored. This directory
20+
* must be absolute, outside of the Drupal installation directory and not
21+
* accessible over the web.
22+
*
23+
* Note: Caches need to be cleared when this value is changed to make the
24+
* private:// stream wrapper available to the system.
25+
*
26+
* See https://www.drupal.org/documentation/modules/file for more information
27+
* about securing private files.
28+
*/
29+
$settings['file_private_path'] = '/var/www/drupal/private/';
30+
31+
// Shared configuration, config_split is used for any site specific differences.
32+
$settings['config_sync_directory'] = '/var/www/drupal/config/sync';
33+
34+
// Content sync module.
35+
global $content_directories;
36+
$content_directories['sync'] = '/var/www/drupal/content/sync';
37+
38+
// Container environment variable path.
39+
$path = "/var/run/s6/container_environment/";
40+
41+
// Some configurations are derived from environment variables.
42+
$config['islandora.settings']['broker_url'] = file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_URL');
43+
$config['islandora.settings']['broker_user'] = file_exists($path . 'DRUPAL_DEFAULT_BROKER_USER') ? file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_USER') : NULL;
44+
$config['islandora.settings']['broker_password'] = file_exists($path . 'DRUPAL_DEFAULT_BROKER_PASSWORD') ? file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_PASSWORD') : NULL;
45+
$config['islandora_iiif.settings']['iiif_server'] = file_get_contents($path . 'DRUPAL_DEFAULT_CANTALOUPE_URL');
46+
$config['openseadragon.settings']['iiif_server'] = file_get_contents($path . 'DRUPAL_DEFAULT_CANTALOUPE_URL');
47+
$config['search_api.server.default_solr_server']['backend_config']['connector_config']['host'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_HOST');
48+
$config['search_api.server.default_solr_server']['backend_config']['connector_config']['port'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_PORT');
49+
$config['search_api.server.default_solr_server']['backend_config']['connector_config']['core'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_CORE');
50+
51+
// Others are hardcoded.
52+
$config['key.key.islandora_rsa_key']['key_provider_settings']['file_location'] = '/opt/keys/jwt/private.key';
53+
54+
// Some settings are derived from environment variables.
55+
$settings['hash_salt'] = file_get_contents($path . 'DRUPAL_DEFAULT_SALT');
56+
$settings['trusted_host_patterns'] = [
57+
0 => file_get_contents($path . 'DRUPAL_DEFAULT_SITE_URL'),
58+
];
59+
60+
// Database settings are also derived from environment variables.
61+
$databases['default']['default'] = [
62+
'database' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_NAME'),
63+
'username' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_USER'),
64+
'password' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_PASSWORD'),
65+
'host' => file_get_contents($path . 'DB_MYSQL_HOST'),
66+
'port' => file_get_contents($path . 'DB_MYSQL_PORT'),
67+
'prefix' => '',
68+
'driver' => 'mysql',
69+
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
70+
];
71+
72+
// Flysystem
73+
$settings['flysystem']['fedora']['driver'] = 'fedora';
74+
$settings['flysystem']['fedora']['config']['root'] = file_get_contents($path . 'DRUPAL_DEFAULT_FCREPO_URL');
75+
76+
// Change the php_storage settings in your setting.php. It is recommend that
77+
// this directory be outside out of the docroot.
78+
$settings['php_storage']['twig']['directory'] = $settings['file_private_path'] . '/php';
79+
$settings['php_storage']['twig']['secret'] = $settings['hash_salt'];
80+
81+
/**
82+
* End Section.
83+
*/

0 commit comments

Comments
 (0)