diff --git a/README.md b/README.md index bf491d5..294c743 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ## What is this? -This repository allows you to quickly install Apache Solr for Drupal 9 into a [Ddev](https://ddev.readthedocs.io) project using just `ddev get drud/ddev-drupal9-solr`. It follows the [Setting up Solr (single core) - the classic way](https://git.drupalcode.org/project/search_api_solr/-/blob/4.x/README.md#setting-up-solr-single-core-the-classic-way) recipe. +This repository allows you to quickly install Apache Solr for Drupal 9+ into a [Ddev](https://ddev.readthedocs.io) project using just `ddev get drud/ddev-drupal9-solr`. It follows the [Setting up Solr (single core) - the classic way](https://git.drupalcode.org/project/search_api_solr/-/blob/4.x/README.md#setting-up-solr-single-core-the-classic-way) recipe. -## Installation on Drupal 9 +## Installation on Drupal 9+ 1. `ddev get drud/ddev-drupal9-solr && ddev restart` 1. You may need to install the relevant Drupal requirements: `ddev composer require drush/drush:* drupal/search_api_solr` @@ -21,11 +21,11 @@ This repository allows you to quickly install Apache Solr for Drupal 9 into a [D ## Explanation -This is the classic Drupal solr:8 recipe used for a long time by Drupal users and compatible with search_api_solr. +This is the classic Drupal `solr:8` image recipe used for a long time by Drupal users and compatible with `search_api_solr`. * It installs a [`.ddev/docker-compose.solr.yaml`](docker-compose.solr.yaml) using the solr:8 docker image. -* A standard Drupal 9 solr configuration is included in [.ddev/solr/conf](solr/conf). -* A [.ddev/docker-entrypoint-initdb.d/solr-configupdate.sh](solr/docker-entrypoint-initdb.d/solr-configupdate.sh) is included and mounted into the solr container so that you can change solr config in .ddev/solr/conf with just a `ddev restart`. +* A standard Drupal 9+ Solr configuration is included in [.ddev/solr/conf](solr/conf). +* A [.ddev/docker-entrypoint-initdb.d/solr-configupdate.sh](solr/docker-entrypoint-initdb.d/solr-configupdate.sh) is included and mounted into the Solr container so that you can change Solr config in `.ddev/solr/conf` with just a `ddev restart`. ## Interacting with Apache Solr @@ -33,7 +33,20 @@ This is the classic Drupal solr:8 recipe used for a long time by Drupal users an * To access the Solr container from inside the web container use: `http://solr:8983/solr/` * A Solr core is automatically created by default with the name "dev"; it can be accessed (from inside the web container) at the URL: `http://solr:8983/solr/dev` or from the host at `http://.ddev.site:8983/solr/#/~cores/dev`. You can obviously create other cores to meet your needs. +## Alternate Core Name + +If you want to use a core name other than the default "dev", add a `.ddev/docker-compose.solr-env.yaml` with these contents, using the core name you want to use: +``` +services: + solr: + environment: + - SOLR_CORENAME=somecorename +``` +1. Remove the #ddev-generated at the top of the file. +2. Change SOLR_CORE environment variable in the `environment:` section. +3. Change your Drupal configuration to use the new core. + ## Caveats -* This recipe won't work with versions of solr before solr:8, and Acquia and Pantheon.io hosting require versions from 3 to 7. You'll want to see the [contributed recipes](https://github.com/drud/ddev-contrib) for older versions of solr. +* This recipe won't work with versions of Solr before `solr:8`, and Acquia and Pantheon.io hosting require versions from 3 to 7. You'll want to see the [contributed recipes](https://github.com/drud/ddev-contrib) for older versions of solr. diff --git a/docker-compose.solr.yaml b/docker-compose.solr.yaml index d9f5413..43f2b8c 100644 --- a/docker-compose.solr.yaml +++ b/docker-compose.solr.yaml @@ -1,4 +1,4 @@ -# DDev Apache Solr recipe file. +# DDEV Apache Solr recipe file. #ddev-generated # # @@ -23,8 +23,6 @@ # accessed at the URL: http://solr:8983/solr/dev (inside web container) # or at http://myproject.ddev.site:8983/solr/dev (on the host) -version: '3.6' - services: solr: # Name of container using standard ddev convention @@ -70,7 +68,9 @@ services: # `chmod +x solr - "./solr/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d" - entrypoint: [ "sh", "-c", "docker-entrypoint.sh solr-precreate dev /solr-conf" ] + # The odd need to use $$SOLR_CORENAME here is explained in + # https://stackoverflow.com/a/48189916/215713 + entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh solr-precreate $${SOLR_CORENAME:-dev} /solr-conf"' external_links: - "ddev-router:${DDEV_SITENAME}.${DDEV_TLD}" diff --git a/install.yaml b/install.yaml index 0994a9c..d543aee 100644 --- a/install.yaml +++ b/install.yaml @@ -4,7 +4,8 @@ pre_install_actions: # files and directories listed here are copied into .ddev project_files: -- solr +- solr/conf +- solr/docker-entrypoint-initdb.d/solr-configupdate.sh - docker-compose.solr.yaml post_install_actions: diff --git a/solr/docker-entrypoint-initdb.d/solr-configupdate.sh b/solr/docker-entrypoint-initdb.d/solr-configupdate.sh index 2ac0dff..1d4c374 100644 --- a/solr/docker-entrypoint-initdb.d/solr-configupdate.sh +++ b/solr/docker-entrypoint-initdb.d/solr-configupdate.sh @@ -2,10 +2,10 @@ #ddev-generated set -e -# Ensure "dev" core config is always up to date even after the +# Ensure "dev" (or alternate SOLR_CORENAME) core config is always up to date even after the # core has been created. This does not execute the first time, # when solr-precreate has not yet run. -CORENAME=dev +CORENAME=${SOLR_CORENAME:-dev} if [ -d /var/solr/data/${CORENAME}/conf ]; then cp /solr-conf/conf/* /var/solr/data/${CORENAME}/conf fi