Skip to content

Commit 0440d2b

Browse files
authored
Allow use of different core name, fixes #12 (#14)
1 parent 586956d commit 0440d2b

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

Diff for: README.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## What is this?
44

5-
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.
5+
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.
66

7-
## Installation on Drupal 9
7+
## Installation on Drupal 9+
88

99
1. `ddev get drud/ddev-drupal9-solr && ddev restart`
1010
1. You may need to install the relevant Drupal requirements: `ddev composer require drush/drush:* drupal/search_api_solr`
@@ -21,19 +21,32 @@ This repository allows you to quickly install Apache Solr for Drupal 9 into a [D
2121

2222
## Explanation
2323

24-
This is the classic Drupal solr:8 recipe used for a long time by Drupal users and compatible with search_api_solr.
24+
This is the classic Drupal `solr:8` image recipe used for a long time by Drupal users and compatible with `search_api_solr`.
2525

2626
* It installs a [`.ddev/docker-compose.solr.yaml`](docker-compose.solr.yaml) using the solr:8 docker image.
27-
* A standard Drupal 9 solr configuration is included in [.ddev/solr/conf](solr/conf).
28-
* 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`.
27+
* A standard Drupal 9+ Solr configuration is included in [.ddev/solr/conf](solr/conf).
28+
* 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`.
2929

3030
## Interacting with Apache Solr
3131

3232
* The Solr admin interface will be accessible at: `http://<projectname>.ddev.site:8983/solr/` For example, if the project is named `myproject` the hostname will be: `http://myproject.ddev.site:8983/solr/`.
3333
* To access the Solr container from inside the web container use: `http://solr:8983/solr/`
3434
* 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://<projectname>.ddev.site:8983/solr/#/~cores/dev`. You can obviously create other cores to meet your needs.
3535

36+
## Alternate Core Name
37+
38+
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:
39+
```
40+
services:
41+
solr:
42+
environment:
43+
- SOLR_CORENAME=somecorename
44+
```
45+
1. Remove the #ddev-generated at the top of the file.
46+
2. Change SOLR_CORE environment variable in the `environment:` section.
47+
3. Change your Drupal configuration to use the new core.
48+
3649
## Caveats
37-
* 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.
50+
* 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.
3851

3952

Diff for: docker-compose.solr.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DDev Apache Solr recipe file.
1+
# DDEV Apache Solr recipe file.
22
#ddev-generated
33
#
44
#
@@ -23,8 +23,6 @@
2323
# accessed at the URL: http://solr:8983/solr/dev (inside web container)
2424
# or at http://myproject.ddev.site:8983/solr/dev (on the host)
2525

26-
version: '3.6'
27-
2826
services:
2927
solr:
3028
# Name of container using standard ddev convention
@@ -70,7 +68,9 @@ services:
7068
# `chmod +x solr
7169
- "./solr/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
7270

73-
entrypoint: [ "sh", "-c", "docker-entrypoint.sh solr-precreate dev /solr-conf" ]
71+
# The odd need to use $$SOLR_CORENAME here is explained in
72+
# https://stackoverflow.com/a/48189916/215713
73+
entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh solr-precreate $${SOLR_CORENAME:-dev} /solr-conf"'
7474

7575
external_links:
7676
- "ddev-router:${DDEV_SITENAME}.${DDEV_TLD}"

Diff for: install.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ pre_install_actions:
44

55
# files and directories listed here are copied into .ddev
66
project_files:
7-
- solr
7+
- solr/conf
8+
- solr/docker-entrypoint-initdb.d/solr-configupdate.sh
89
- docker-compose.solr.yaml
910

1011
post_install_actions:

Diff for: solr/docker-entrypoint-initdb.d/solr-configupdate.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#ddev-generated
33
set -e
44

5-
# Ensure "dev" core config is always up to date even after the
5+
# Ensure "dev" (or alternate SOLR_CORENAME) core config is always up to date even after the
66
# core has been created. This does not execute the first time,
77
# when solr-precreate has not yet run.
8-
CORENAME=dev
8+
CORENAME=${SOLR_CORENAME:-dev}
99
if [ -d /var/solr/data/${CORENAME}/conf ]; then
1010
cp /solr-conf/conf/* /var/solr/data/${CORENAME}/conf
1111
fi

0 commit comments

Comments
 (0)