From 8468338c50962c6a4bb0a04a823a008bfdc2fef7 Mon Sep 17 00:00:00 2001 From: omars Date: Tue, 20 May 2025 18:18:37 +0300 Subject: [PATCH 1/3] update docker images, solr v9 --- Dockerfile | 11 +++++++---- tests/docker/Dockerfile | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a54c6162..c5bfa227 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ -FROM php:8.4-cli +FROM php:8.4-cli-alpine3.20 -RUN apt update && apt install libxml2-dev libcurl4-gnutls-dev --yes +RUN apk add --no-cache libxml2-dev libcurl-dev \ + && docker-php-ext-install xml curl \ + && rm -rf /var/cache/apk/* -RUN apt install vim --yes +RUN apk add --no-cache vim \ + && rm -rf /var/cache/apk/* COPY .docker/entrypoint.sh /opt/ @@ -12,4 +15,4 @@ COPY ./ /opt/solr2 WORKDIR /opt/solr2 -ENTRYPOINT ["sh","/opt/entrypoint.sh"] +ENTRYPOINT ["sh","/opt/entrypoint.sh"] \ No newline at end of file diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index d2295aa4..6d06d7ea 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM solr:6.3 +FROM bitnami/solr:9.8.1 COPY collections collections From 013673dc143ef7f8f42fa352919a87781b4da96c Mon Sep 17 00:00:00 2001 From: omars44 Date: Mon, 17 Nov 2025 09:33:56 +0200 Subject: [PATCH 2/3] docker: fix test setup --- docker-compose.yml | 4 +--- tests/docker/Dockerfile | 12 +++--------- tests/docker/init-solr.sh | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 tests/docker/init-solr.sh diff --git a/docker-compose.yml b/docker-compose.yml index 46e7e44c..770746e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,5 @@ -version: '2.1' - services: solr: build: tests/docker/ ports: - - "8983:8983" + - "127.0.0.1:8983:8983" diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 6d06d7ea..8c967453 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,11 +1,5 @@ -FROM bitnami/solr:9.8.1 +FROM solr:9.10.0-slim -COPY collections collections +COPY collections /opt/solr-configs -RUN solr start &&\ - solr create -c collection1 &&\ - solr create -c metal_store &&\ - solr create -c myfiles &&\ - curl 'http://localhost:8983/solr/collection1/update/json?commit=true' --data-binary @collections/collection1.json -H 'Content-type:application/json' &&\ - curl 'http://localhost:8983/solr/metal_store/update/json?commit=true' --data-binary @collections/metal_store.json -H 'Content-type:application/json' &&\ - solr stop +COPY --chmod=755 init-solr.sh /docker-entrypoint-initdb.d/init-solr.sh \ No newline at end of file diff --git a/tests/docker/init-solr.sh b/tests/docker/init-solr.sh new file mode 100644 index 00000000..0f73af30 --- /dev/null +++ b/tests/docker/init-solr.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +echo "Starting temporary Solr server for initialization..." +solr start + +echo "Solr server is running. Creating collections with default configs..." + +solr create -c collection1 +solr create -c metal_store +solr create -c myfiles + +echo "Collections created. Indexing data..." + +curl 'http://localhost:8983/solr/collection1/update/json?commit=true' --data-binary @/opt/solr-configs/collection1.json -H 'Content-type:application/json' +curl 'http://localhost:8983/solr/metal_store/update/json?commit=true' --data-binary @/opt/solr-configs/metal_store.json -H 'Content-type:application/json' + +echo "Data indexed. Stopping temporary Solr server..." +solr stop +echo "Solr initialization complete." \ No newline at end of file From f070c2ce44e5dc6bb4239302598bcc8ea5f1ffa4 Mon Sep 17 00:00:00 2001 From: omars44 Date: Mon, 17 Nov 2025 10:14:55 +0200 Subject: [PATCH 3/3] fix existing collection error --- README.INSTALLATION | 8 +++----- README.md | 29 ++++++++++++++++++++++++----- tests/docker/Dockerfile | 12 ++++++++++-- tests/docker/init-solr.sh | 30 ++++++++++++++++++++++-------- 4 files changed, 59 insertions(+), 20 deletions(-) diff --git a/README.INSTALLATION b/README.INSTALLATION index 2b9d18f1..41cb5449 100644 --- a/README.INSTALLATION +++ b/README.INSTALLATION @@ -2,7 +2,7 @@ PHP VERSION Dependencies ================================================================================ -PHP version 7.0 or later is needed +PHP version 8.0 or later is needed ================================================================================ Extension Dependencies @@ -224,10 +224,8 @@ http://windows.php.net/downloads/snaps/php-5.3/php-5.3-src-latest.zip How to Report Bugs ================================================================================ -Please report bugs to omars@php.net +Please report bugs to -You can also register bugs here - -http://pecl.php.net/bugs/report.php?package=solr +https://github.com/php/pecl-search_engine-solr/issues Thank you for using PHP diff --git a/README.md b/README.md index 4df7bf15..c4a9d157 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,34 @@ For RHEL/Fedora/CentOS/Scientific linux Please make sure to install them before proceeding to the compilation process ```bash - phpize - ./configure - make - make test - sudo make install +phpize +./configure +make +make test +sudo make install ``` more details on README.INSTALLATION +Local Dev Environment +--------------------- + +```bash +docker-compose up -d +# OR +docker-compose up --build -d + +phpize +./configure +make + +export SOLR_SERVER_CONFIGURED=1 +php run-tests.php -q -d extension=$PWD/modules/solr.so --show-diff +# OR run a single test +php run-tests.php -q -d extension=$PWD/modules/solr.so --show-diff tests/004.solrclient_query_terms.phpt + +``` + Contributions ------------- All forms of contributions are welcome! Whether contributing to tests, or the source. diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 8c967453..ad08d5fb 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,5 +1,13 @@ -FROM solr:9.10.0-slim +FROM solr:7-slim + +USER root + +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl && \ + rm -rf /var/lib/apt/lists/* COPY collections /opt/solr-configs -COPY --chmod=755 init-solr.sh /docker-entrypoint-initdb.d/init-solr.sh \ No newline at end of file +COPY --chmod=755 init-solr.sh /docker-entrypoint-initdb.d/init-solr.sh + +USER solr \ No newline at end of file diff --git a/tests/docker/init-solr.sh b/tests/docker/init-solr.sh index 0f73af30..16a3a862 100644 --- a/tests/docker/init-solr.sh +++ b/tests/docker/init-solr.sh @@ -3,18 +3,32 @@ set -e echo "Starting temporary Solr server for initialization..." solr start +echo "Solr server is running." -echo "Solr server is running. Creating collections with default configs..." +create_and_index() { + COLLECTION_NAME=$1 + DATA_FILE=$2 -solr create -c collection1 -solr create -c metal_store -solr create -c myfiles + echo "Checking if collection '$COLLECTION_NAME' exists..." -echo "Collections created. Indexing data..." + if curl -s "http://localhost:8983/solr/admin/collections?action=LIST" | grep -q "\"$COLLECTION_NAME\""; then + echo "Collection '$COLLECTION_NAME' already exists. Skipping creation and indexing." + else + echo "Collection '$COLLECTION_NAME' not found. Creating..." + solr create -c "$COLLECTION_NAME" -curl 'http://localhost:8983/solr/collection1/update/json?commit=true' --data-binary @/opt/solr-configs/collection1.json -H 'Content-type:application/json' -curl 'http://localhost:8983/solr/metal_store/update/json?commit=true' --data-binary @/opt/solr-configs/metal_store.json -H 'Content-type:application/json' + if [ -n "$DATA_FILE" ] && [ -f "$DATA_FILE" ]; then + echo "Indexing data for '$COLLECTION_NAME' from $DATA_FILE..." + curl "http://localhost:8983/solr/$COLLECTION_NAME/update/json?commit=true" --data-binary @"$DATA_FILE" -H 'Content-type:application/json' + else + echo "No data file provided or found for '$COLLECTION_NAME'. Skipping indexing." + fi + fi +} -echo "Data indexed. Stopping temporary Solr server..." +create_and_index "collection1" "/opt/solr-configs/collection1.json" +create_and_index "metal_store" "/opt/solr-configs/metal_store.json" + +echo "Data initialization finished. Stopping temporary Solr server..." solr stop echo "Solr initialization complete." \ No newline at end of file