diff --git a/.gitignore b/.gitignore index 8eba6c8..b1c1508 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ src/ +docker-volumes/ diff --git a/README.md b/README.md index a2e9339..6bee990 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,86 @@ -# Docker container for HBP-Lucene-Solr # +# Docker container for HBP-Lucene/Solr # Copyright (c) 2017-2018 2017 [DIAS](https://dias.epfl.ch/BrainDB) laboratory --- -This project creates a lightweight Docker image for running HBP Spatial Search Service (API) based on . - -It has been developed on Ubuntu and not tested on other platforms. +This project creates a lightweight Docker image of a customized *Lucene/Solr* implementation ([HBP-Lucene/Solr](https://bitbucket.org/sakurad/hbp-lucene-solr)) for running HBP Spatial Search Service (API). --- ## Quick-start ## **1. Clone this project** ```sh $ git clone git@bitbucket.org:sakurad/hbp-lucene-solr-docker.git $ cd hbp-lucene-solr-docker ``` **2. Clone the HBP-Lucene/Solr sources and build it** ```sh $ git clone git@bitbucket.org:sakurad/hbp-lucene-solr.git src/hbp-lucene-solr -$ cd src/hbp-lucene-solr && ant compile && cd solr && ant package +$ cd src/hbp-lucene-solr && ant compile && cd solr && ant package && cd ../../../ ``` **3. Build the docker image** ```sh $ docker build -t hpb-lucene-solr \ # --build-arg JOBS=8 \ --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ --build-arg VCS_REF=`git -C ./src/ rev-parse --short HEAD` \ . ``` -**Note:** +**_Note:_** * If you update the sources, add `--no-cache=true` to the command above to take the new version in consideration. * Option `-t , --tag list`: Name and optionally a tag in the 'name:tag' format * Replace the `8` in `JOBS=8` with the number of CPU threads to reduce the build time on your machine. +**4. Use the built image** +```sh +$ docker run --rm --name my-hbp-solr -d -p 8983:8983 hbp-lucene-solr +``` + +## Using a custom `SOLR_HOME` (outside container) ## --- -## Use the built image ## +To use a custom *Solr home* directory directory on the host system (outside the container), we can employ a `SOLR_HOME` environment variable by setting it to the desired location (which is now inside the container in its default location at `/opt/hbp-lucene-solr/server/solr`). We support this in hbp-lucene-solr-docker, in combination with volumes: +```sh +docker run -it -v $PWD/mysolrhome:/mysolrhome -e SOLR_HOME=/mysolrhome hbp-lucene-solr +``` -To start Spatial Search API service, you will need three folders to store the following files: +This does need a pre-configured directory at that location (`/mysolrhome`). -1. Lucene index files (actual data) -2. ZooKeeper configuration files -3. Solr configuration files +As such, hbp-lucene-solr-docker supports a `INIT_SOLR_HOME` setting, which +copies the contents from the default directory in the image to the `SOLR_HOME` +(the newly specified must be empty). +```sh +$ mkdir -p docker-volumes/hbp-solr1 +$ sudo chown 8983:8983 docker-volumes/hbp-solr1 +$ docker run -it -v $PWD/docker-volumes/hbp-solr1:/hbp-solr1 \ + -e SOLR_HOME=/hbp-solr1 -e INIT_SOLR_HOME=yes \ + hbp-lucene-solr +``` -You can then start the container with the following command: +## Putting it all together ## +--- + +The following is used to run the Spatial Search API in production mode: ```sh -$ docker run --rm --name my-hbp-solr -d -p 8983:8983 -t hbp-lucene-solr +$ mkdir -p docker-volumes/hbp-solr1 +$ sudo chown 8983:8983 docker-volumes/hbp-solr1 +$ docker run \ + --name my-hbp-solr \ + -d \ + -p 8983:8983 \ + -it \ + -v $PWD/docker-volumes/hbp-solr1:/hbp-solr1 \ + -e SOLR_HOME=/hbp-solr1 \ + -e INIT_SOLR_HOME=yes \ + -e SOLR_HEAP=12g \ + hbp-lucene-solr ``` +Note increased memory size (12GB). + diff --git a/scripts/init-hbp-solr-home b/scripts/init-hbp-solr-home index 22c0803..7a80259 100755 --- a/scripts/init-hbp-solr-home +++ b/scripts/init-hbp-solr-home @@ -1,50 +1,50 @@ #!/bin/bash # # A helper script to initialise a custom SOLR_HOME. # For example: # # mkdir mysolrhome # sudo chown 8983:8983 mysolrhome # docker run -it -v $PWD/mysolrhome:/mysolrhome -e SOLR_HOME=/mysolrhome -e INIT_SOLR_HOME=yes hbp-solr # set -e if [[ "$VERBOSE" = "yes" ]]; then set -x fi # Normally SOLR_HOME is not set, and Solr will use /opt/solr/server/solr/ # If it's not set, then this script has no relevance. if [[ -z $SOLR_HOME ]]; then exit fi # require an explicit opt-in. Without this, you can use the SOLR_HOME and # volumes, and configure it from the command-line or a docker-entrypoint-initdb.d # script if [[ "$INIT_SOLR_HOME" != "yes" ]]; then exit fi # check the directory exists. if [ ! -d "$SOLR_HOME" ]; then echo "SOLR_HOME $SOLR_HOME does not exist" exit 1 fi # check for existing Solr if [ -f "$SOLR_HOME/solr.xml" ]; then exit fi # refuse to use non-empty directories, which are likely a misconfiguration if [ "$(find "$SOLR_HOME" -mindepth 1 ! -name lost+found | wc -l)" != '0' ]; then echo "SOLR_HOME directory $SOLR_HOME is not empty; refusing to create a solr home." exit 1 fi # populate with default solr home contents echo "copying solr home contents to $SOLR_HOME" -cp -R /opt/solr/server/solr/* "$SOLR_HOME" +cp -R /opt/hbp-lucene-solr/server/solr/* "$SOLR_HOME"