This is an automated email from the ASF dual-hosted git repository. fgreg pushed a commit to branch SDAP-166 in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git
commit d6ebc189c40845c31233703c8ef3d6971ebd6964 Author: Frank Greguska <[email protected]> AuthorDate: Wed Nov 14 17:38:28 2018 -0800 New Solr Cloud docker image --- docker/solr/Readme.rst | 29 +++++----- .../create-core.sh => cloud/Dockerfile} | 21 ++++--- docker/solr/cloud/Readme.rst | 66 ++++++++++++++++++++++ .../create-core.sh => cloud/bootstrap-zk.sh} | 7 +-- docker/solr/singlenode/Readme.rst | 4 +- 5 files changed, 97 insertions(+), 30 deletions(-) diff --git a/docker/solr/Readme.rst b/docker/solr/Readme.rst index bb88630..e4acecd 100644 --- a/docker/solr/Readme.rst +++ b/docker/solr/Readme.rst @@ -1,28 +1,23 @@ Solr Images ===================== -All docker builds for the Solr images should happen from this directory. For copy/paste ability, first export the environment variable `BUILD_VERSION` to the version number you would like to tag images as. +All docker builds for the Solr images should happen from this directory. For copy/paste ability, first export the environment variable ``BUILD_VERSION`` to the version number you would like to tag images as. -Environment Variables ---------------------- +Common Environment Variables +------------------------------ Any environment variable that can be passed to `solr.in.sh <https://github.com/apache/lucene-solr/blob/95d01c6583b825b6b87591e4f27002c285ea25fb/solr/bin/solr.in.sh>`_ and be passed as an environment variable to the docker container and it will be utilized. A few options are called out here: -SOLR_HEAP -^^^^^^^^^ +======================== ======================== ============= + Variable Default Description +======================== ======================== ============= +``SOLR_HEAP`` ``localhost`` Increase Java Heap as needed to support your indexing / query needs +``SOLR_HOME`` ``/usr/local/solrhome`` Path to a directory for Solr to store cores and their data. -Increase Java Heap as needed to support your indexing / query needs. Example: + This directory is exposed as a ``VOLUME`` that can be mounted. +======================== ======================== ============= -.. code-block:: bash - - SOLR_HEAP="512m" - -SOLR_HOME -^^^^^^^^^ - -Path to a directory for Solr to store cores and their data. This image by default sets this environment variable to `/usr/local/solrhome` and exposes that directory as a `VOLUME` that can be mounted. You can change this to anything you want to change the location of the configuration/cores/data within the docker container, but it is recommended to simply leave it at the default. - -In either case (leave as default or change to custom location) if you want to mount the SOLR_HOME directory to a directory on the host machine, you need to provide the container path to the docker run `-v` option. Doing this allows you to retain the index between start/stop of this container. +If you want to mount the ``SOLR_HOME`` directory to a directory on the host machine, you need to provide the container path to the docker run ``-v`` option. Doing this allows you to retain the index between start/stop of this container. sdap/solr --------- @@ -44,3 +39,5 @@ How to Run This image is not intended to be run directly .. include:: ../docker/solr/singlenode/Readme.rst + +.. include:: ../docker/solr/cloud/Readme.rst diff --git a/docker/solr/singlenode/create-core.sh b/docker/solr/cloud/Dockerfile old mode 100755 new mode 100644 similarity index 64% copy from docker/solr/singlenode/create-core.sh copy to docker/solr/cloud/Dockerfile index 1520b6a..baf42d1 --- a/docker/solr/singlenode/create-core.sh +++ b/docker/solr/cloud/Dockerfile @@ -1,4 +1,3 @@ -#!/bin/bash -ex # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -14,12 +13,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +ARG tag_version=latest +FROM sdap/solr:${tag_version} +MAINTAINER Apache SDAP "[email protected]" -set -ex +WORKDIR /opt/solr +VOLUME ${SOLR_HOME} -SOLR_HOME=${SOLR_HOME:=/opt/solr/server/solr/} -mkdir -p ${SOLR_HOME}/nexustiles -sudo cp -r /tmp/nexustiles/* ${SOLR_HOME}/nexustiles/ -sudo chown -R ${SOLR_USER}:${SOLR_GROUP} ${SOLR_HOME}/nexustiles +ENV INIT_SOLR_HOME="yes" \ + SDAP_ZK_SERVICE_HOST="localhost" \ + SDAP_ZK_SERVICE_PORT="2181" \ + SDAP_ZK_SOLR_CHROOT="solr" \ + SOLR_HOST="localhost" -set +x +COPY ./cloud/bootstrap-zk.sh /docker-entrypoint-initdb.d/bootstrap-zk.sh + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["solr-foreground"] diff --git a/docker/solr/cloud/Readme.rst b/docker/solr/cloud/Readme.rst new file mode 100644 index 0000000..b0b7bc4 --- /dev/null +++ b/docker/solr/cloud/Readme.rst @@ -0,0 +1,66 @@ +sdap/solr-cloud +-------------------- + +This is the cloud version of Solr. + +How To Build +^^^^^^^^^^^^ + +This image can be built from the incubator/sdap/solr directory: + +.. code-block:: bash + + docker build -t sdap/solr-cloud:${BUILD_VERSION} -f cloud/Dockerfile --build-arg tag_version=${BUILD_VERSION} . + +How to Run +^^^^^^^^^^ + +This Docker container runs Apache Solr v7.4 in cloud mode with the nexustiles collection. It requires a running Zookeeper service in order to work. It will automatically bootstrap Zookeeper by uploading configuration and core properties to Zookeeper when it starts. + +It is necessary to decide wether or not you want data to persist when the container is stopped or if the data should be discarded. + +Cloud Specific Environment Variables +"""""""""""""""""""""""""""""""""""" + +======================== =============== ============= + Variable Default Description +======================== =============== ============= +``SDAP_ZK_SERVICE_HOST`` ``localhost`` This is the hostname of the Zookeeper service that Solr should use to connect. +``SDAP_ZK_SERVICE_PORT`` ``2181`` The port Solr should try to connect to Zookeeper with. +``SDAP_ZK_SOLR_CHROOT`` ``solr`` The Zookeeper chroot under which Solr configuration will be accessed. +``SOLR_HOST`` ``localhost`` The hostname of the Solr instance that will be recored in Zookeeper. +======================== =============== ============= + +Zookeeper +"""""""""""" + +Zookeeper can be running on the host machine or anywhere that docker can access (e.g. a bridge network). Take note of the host where Zookeeper is running and use that value for the ``SDAP_ZK_SERVICE_HOST`` environment variable. + +.. note:: + + If you choose to run Zookeeper on the host machine and you are using Docker For Mac, you can use the special hostname ``host.docker.internal`` to access the host from inside a container. + + +Persist Data +"""""""""""" + +If you want to persist the data between runs, provide a volume mount from the host machine to the container path where ``SOLR_HOME`` is. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/usr/local/solrhome``. +This also assumes you are running Zookeeper on the host machine and that you are using Docker for Mac. + +.. code-block:: bash + + docker run --name solr -v ${PWD}/solrhome:/usr/local/solrhome -p 8083:8083 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" sdap/solr-cloud:${VERSION} + +``${PWD}/solrhome`` is the directory on host machine where ``SOLR_HOME`` will be created if it does not already exist. + +Don't Persist Data +"""""""""""""""""" + +If you do not need to persist data between runs of this image, just simply run the image without a volume mount. +This also assumes you are running Zookeeper on the host machine and that you are using Docker for Mac. + +.. code-block:: bash + + docker run --name solr -p 8083:8083 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" sdap/solr-cloud:${VERSION} + +When the container is removed, the data will be lost. diff --git a/docker/solr/singlenode/create-core.sh b/docker/solr/cloud/bootstrap-zk.sh similarity index 79% rename from docker/solr/singlenode/create-core.sh rename to docker/solr/cloud/bootstrap-zk.sh index 1520b6a..c8dc2aa 100755 --- a/docker/solr/singlenode/create-core.sh +++ b/docker/solr/cloud/bootstrap-zk.sh @@ -17,9 +17,6 @@ set -ex -SOLR_HOME=${SOLR_HOME:=/opt/solr/server/solr/} -mkdir -p ${SOLR_HOME}/nexustiles -sudo cp -r /tmp/nexustiles/* ${SOLR_HOME}/nexustiles/ -sudo chown -R ${SOLR_USER}:${SOLR_GROUP} ${SOLR_HOME}/nexustiles +ZK_HOST="${SDAP_ZK_SERVICE_HOST}:${SDAP_ZK_SERVICE_PORT}/${SDAP_ZK_SOLR_CHROOT}" -set +x +./server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd bootstrap -solrhome ${SOLR_HOME} diff --git a/docker/solr/singlenode/Readme.rst b/docker/solr/singlenode/Readme.rst index e47317d..2b8c94a 100644 --- a/docker/solr/singlenode/Readme.rst +++ b/docker/solr/singlenode/Readme.rst @@ -20,13 +20,13 @@ This Docker container runs Apache Solr v7.4 as a single node with the nexustiles Persist Data """""""""""" -To persist the data, we need to provide a volume mount from the host machine to the container path where `SOLR_HOME` is. If you do not provide a custom `SOLR_HOME` location, the default is `/usr/local/solrhome`. Therefore, the easiest way to run this image and persist data to a location on the host machine is: +To persist the data, we need to provide a volume mount from the host machine to the container path where ``SOLR_HOME`` is. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/usr/local/solrhome``. Therefore, the easiest way to run this image and persist data to a location on the host machine is: .. code-block:: bash docker run --name solr -v ${PWD}/solrhome:/usr/local/solrhome -p 8083:8083 -d sdap/solr-singlenode:${VERSION} -${PWD}/solrhome is the directory on host machine where `SOLR_HOME` will be created if it does not already exist. If you have run this container before and ${PWD}/solrhome already contains files, those files will not be overwritten and will be used. +``${PWD}/solrhome`` is the directory on host machine where ``SOLR_HOME`` will be created if it does not already exist. If you have run this container before and ``${PWD}/solrhome`` already contains files, those files will not be overwritten and will be used. Don't Persist Data """"""""""""""""""
