From 842765d31a9b56889ea2505b0ab75aaadecc79a9 Mon Sep 17 00:00:00 2001 From: bach Date: Wed, 11 Nov 2026 20:33:53 +0100 Subject: [PATCH] Solr 9 local instance (solr9, :8986, configsets from solr_cores_stage worktree) - make solr8 / make solr9 switches local Drupal via untracked settings.solr.php - update_solr_config.sh clears conf/ before unzipping the generated config Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + Makefile | 8 +++++++- bin/solr_switch.sh | 20 ++++++++++++++++++++ bin/update_solr_config.sh | 6 ++++-- docker-compose.yml | 17 +++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100755 bin/solr_switch.sh diff --git a/.gitignore b/.gitignore index 81e2d2a..b67fad0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ ai-docs/ solr_cores_stage/ AGENTS.md .vibe/ +var_solr9/ diff --git a/Makefile b/Makefile index fe2b15f..3689598 100644 --- a/Makefile +++ b/Makefile @@ -112,4 +112,10 @@ dump_d8_db: docker exec materiod8-mysql-1 sh -c 'exec mariadb-dump -uroot -pmaterio materio_d8' > ./ressources/materio-d8-$(DATE_NOW)-local.sql sish: - ssh -p 2222 -R materio:80:dev:8890 CT-sish.me \ No newline at end of file + ssh -p 2222 -R materio:80:dev:8890 CT-sish.me + +solr8: + bin/solr_switch.sh 8 + +solr9: + bin/solr_switch.sh 9 diff --git a/bin/solr_switch.sh b/bin/solr_switch.sh new file mode 100755 index 0000000..ed55aa8 --- /dev/null +++ b/bin/solr_switch.sh @@ -0,0 +1,20 @@ +#! /bin/bash +# Bascule le Drupal local entre Solr 8 (branche prod) et Solr 9 (branche stage). +# bin/solr_switch.sh 8|9 +# Écrit (ou supprime) web/sites/default/settings.solr.php, inclus par settings.php, puis drush cr. +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 1 +F=public_html/web/sites/default/settings.solr.php +case "$1" in + 8) rm -f "$F" ;; + 9) cat > "$F" <<'PHP' + conteneur solr9 (Solr 9) +foreach (['materio', 'database_search_autocomplete'] as $server) { + $config["search_api.server.$server"]['backend_config']['connector_config']['host'] = 'solr9'; + $config["search_api.server.$server"]['backend_config']['connector_config']['solr_version'] = '9'; +} +PHP + ;; + *) echo "usage: $0 8|9" >&2; exit 1 ;; +esac +docker exec materiod8-php-1 drush cr >/dev/null && echo "Drupal local -> Solr $1" diff --git a/bin/update_solr_config.sh b/bin/update_solr_config.sh index d757130..fa2003d 100755 --- a/bin/update_solr_config.sh +++ b/bin/update_solr_config.sh @@ -3,7 +3,7 @@ # puis recharge les cores (RELOAD, sans restart). # # bin/update_solr_config.sh -> solr_cores (branche prod, Solr 8, :8985) -# bin/update_solr_config.sh solr_cores_stage URL -> worktree stage (Solr 9, phase 2) +# bin/update_solr_config.sh solr_cores_stage http://localhost:8986/solr -> worktree stage (Solr 9, après make solr9) # # Les modifications restent à relire / committer dans l'arbre visé (git diff). @@ -22,8 +22,10 @@ docker exec -i materiod8-php-1 drush solr-gsc database_search_autocomplete confi mkdir -p ressources/solr/ mv public_html/web/config.zip ressources/solr/ || exit 1 +# conf/ entièrement généré : on vide avant de décompresser (les fichiers retirés apparaissent dans git status) for core in $CORES; do - unzip -o ressources/solr/config.zip -d "$TREE/$core/conf" + find "$TREE/$core/conf" -type f -delete + unzip -q -o ressources/solr/config.zip -d "$TREE/$core/conf" done for core in $CORES; do diff --git a/docker-compose.yml b/docker-compose.yml index cbdd688..8dcb49d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,6 +74,22 @@ services: ports: - 8985:8983 + # Solr 9 pour la branche stage (même structure, configsets = worktree solr_cores_stage) + solr9: + image: solr:9.11.0 + environment: + - SOLR_HOME=/var/solr/data + - SOLR_MODULES=extraction,langid,ltr,analysis-extras + # Solr 9 (security manager) : autorise la lecture des configsets hors SOLR_HOME + - SOLR_OPTS=-Dsolr.allowPaths=/opt/configsets + volumes: + - ./var_solr9:/var/solr + - ./solr_cores_stage:/opt/configsets:ro + networks: + - solr + ports: + - 8986:8983 + # solr-legacy: # build: ./Docker/solr-legacy/ # volumes: @@ -113,6 +129,7 @@ services: # - mysql-legacy - redis - solr + - solr9 # php-legacy: # build: ./Docker/php-legacy/