diff --git a/Makefile b/Makefile index 361e91f4b..473cd0b8c 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,11 @@ starter: generate-secrets docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'cd /home/root && composer install'; \ fi $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter + rm ./codebase/assets/patches/default_settings.txt + cp default_settings.txt ./codebase/assets/patches + $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter $(MAKE) compose-up + docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx /var/www/drupal/ ; su nginx -s /bin/bash -c "composer install"' $(MAKE) starter-finalize ENVIRONMENT=starter @@ -172,6 +176,9 @@ starter_dev: generate-secrets 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;'; \ fi $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev + rm ./codebase/assets/patches/default_settings.txt + cp default_settings.txt ./codebase/assets/patches + $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev $(MAKE) compose-up docker compose exec -T -u nginx drupal sh -c 'composer install' $(MAKE) starter-finalize ENVIRONMENT=starter_dev @@ -551,7 +558,7 @@ delete-shortcut-entities: .PHONY: hydrate .SILENT: hydrate ## Reconstitute the site from environment variables. -hydrate: update-settings-php update-config-from-environment solr-cores namespaces run-islandora-migrations +hydrate: update-config-from-environment solr-cores namespaces run-islandora-migrations docker compose exec -T drupal drush cr -y @@ -576,7 +583,8 @@ starter-init: init .PHONY: starter-finalize starter-finalize: docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx . ; echo "Chown Complete"' - $(MAKE) drupal-database update-settings-php + $(MAKE) drupal-database + 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)'" docker compose exec -T drupal with-contenv bash -lc "drush cr" docker compose exec -T drupal with-contenv bash -lc "drush -l $(SITE) user:role:add fedoraadmin admin" diff --git a/build/docker-compose/docker-compose.drupal.yml b/build/docker-compose/docker-compose.drupal.yml index afd2a98b4..6bdfd56c7 100644 --- a/build/docker-compose/docker-compose.drupal.yml +++ b/build/docker-compose/docker-compose.drupal.yml @@ -8,10 +8,10 @@ services: drupal: restart: ${RESTART_POLICY:-unless-stopped} environment: + DRUPAL_DEFAULT_BROKER_URL: tcp://activemq:61613 DRUPAL_DEFAULT_CANTALOUPE_URL: https://${DOMAIN}/cantaloupe/iiif/2 - DRUPAL_DEFAULT_FCREPO_HOST: ${DOMAIN} - DRUPAL_DEFAULT_FCREPO_PORT: 8081 - DRUPAL_DEFAULT_SITE_URL: http://${DOMAIN} # Make sure this is just http and not https! + DRUPAL_DEFAULT_FCREPO_URL: http://${DOMAIN}:8081/fcrepo/rest/ + DRUPAL_DEFAULT_SITE_URL: ${DOMAIN} DRUPAL_DEFAULT_PROFILE: ${DRUPAL_INSTALL_PROFILE} PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT} PHP_POST_MAX_SIZE: ${PHP_POST_MAX_SIZE} diff --git a/default_settings.txt b/default_settings.txt new file mode 100644 index 000000000..02aa1c328 --- /dev/null +++ b/default_settings.txt @@ -0,0 +1,83 @@ +/** + * Section appended onto drupal/core default.settings.php via "drupal-scaffold" in composer.json. + */ + +// Let Drush use all the memory available. +if (PHP_SAPI === 'cli') { + ini_set('memory_limit', '-1'); +} + +// Required when running Drupal behind a reverse proxy. +$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; + +/** + * Private file path: + * + * A local file system path where private files will be stored. This directory + * must be absolute, outside of the Drupal installation directory and not + * accessible over the web. + * + * Note: Caches need to be cleared when this value is changed to make the + * private:// stream wrapper available to the system. + * + * See https://www.drupal.org/documentation/modules/file for more information + * about securing private files. + */ +$settings['file_private_path'] = '/var/www/drupal/private/'; + +// Shared configuration, config_split is used for any site specific differences. +$settings['config_sync_directory'] = '/var/www/drupal/config/sync'; + +// Content sync module. +global $content_directories; +$content_directories['sync'] = '/var/www/drupal/content/sync'; + +// Container environment variable path. +$path = "/var/run/s6/container_environment/"; + +// Some configurations are derived from environment variables. +$config['islandora.settings']['broker_url'] = file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_URL'); +$config['islandora.settings']['broker_user'] = file_exists($path . 'DRUPAL_DEFAULT_BROKER_USER') ? file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_USER') : NULL; +$config['islandora.settings']['broker_password'] = file_exists($path . 'DRUPAL_DEFAULT_BROKER_PASSWORD') ? file_get_contents($path . 'DRUPAL_DEFAULT_BROKER_PASSWORD') : NULL; +$config['islandora_iiif.settings']['iiif_server'] = file_get_contents($path . 'DRUPAL_DEFAULT_CANTALOUPE_URL'); +$config['openseadragon.settings']['iiif_server'] = file_get_contents($path . 'DRUPAL_DEFAULT_CANTALOUPE_URL'); +$config['search_api.server.default_solr_server']['backend_config']['connector_config']['host'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_HOST'); +$config['search_api.server.default_solr_server']['backend_config']['connector_config']['port'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_PORT'); +$config['search_api.server.default_solr_server']['backend_config']['connector_config']['core'] = file_get_contents($path . 'DRUPAL_DEFAULT_SOLR_CORE'); + +// Others are hardcoded. +$config['key.key.islandora_rsa_key']['key_provider_settings']['file_location'] = '/opt/keys/jwt/private.key'; + +// Some settings are derived from environment variables. +$settings['hash_salt'] = file_get_contents($path . 'DRUPAL_DEFAULT_SALT'); +$settings['trusted_host_patterns'] = [ + 0 => file_get_contents($path . 'DRUPAL_DEFAULT_SITE_URL'), +]; + +// Database settings are also derived from environment variables. +$databases['default']['default'] = [ + 'database' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_NAME'), + 'username' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_USER'), + 'password' => file_get_contents($path . 'DRUPAL_DEFAULT_DB_PASSWORD'), + 'host' => file_get_contents($path . 'DB_MYSQL_HOST'), + 'port' => file_get_contents($path . 'DB_MYSQL_PORT'), + 'prefix' => '', + 'driver' => 'mysql', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', +]; + +// Flysystem +$settings['flysystem']['fedora']['driver'] = 'fedora'; +$settings['flysystem']['fedora']['config']['root'] = file_get_contents($path . 'DRUPAL_DEFAULT_FCREPO_URL'); + +// Change the php_storage settings in your setting.php. It is recommend that +// this directory be outside out of the docroot. +$settings['php_storage']['twig']['directory'] = $settings['file_private_path'] . '/php'; +$settings['php_storage']['twig']['secret'] = $settings['hash_salt']; + +/** + * End Section. + */