Run Solr in Openshift

Get a running solr instance on Openshift with s2i images

Albert Lacambra BasilAlbert Lacambra Basil

Create docker file

FROM solr:8.2.0

MAINTAINER  Albert Lacambra Basil ""
USER root
ENV STI_SCRIPTS_PATH=/usr/libexec/s2i

LABEL io.k8s.description="Run SOLR search in OpenShift" \
      io.k8s.display-name="SOLR 6.6" \
      io.openshift.expose-services="8983:http" \
      io.openshift.tags="builder,solr,solr8.2.0" \

COPY ./s2i/bin/. ${STI_SCRIPTS_PATH}
RUN chmod -R a+rx ${STI_SCRIPTS_PATH}

# If we need to add files as part of every SOLR conf, they'd go here
# COPY ./solr-config/ /tmp/solr-config
# Give the SOLR directory to root group (not root user)

RUN chgrp -R 0 /opt/solr \
  && chmod -R g+rwX /opt/solr

RUN chgrp -R 0 /opt/docker-solr \
  && chmod -R g+rwX /opt/docker-solr

USER 8983

Build Dockerimage

SCRIPT_DIR=$(dirname $0)

docker build -t 'alacambra/openshift-solr:8.2.0' -f ${SCRIPT_DIR}/Dockerfile ${SCRIPT_DIR}

Import ImageStream

oc import-image s2i-solr --from="alacambra/openshift-solr:8.2.0" --confirm

Create App

create new app with solr config files:
oc new-app s2i-solr:8.2.0~/{path/to/s2i-solr/solr/} --name=solr-blog

Reabuild app

rebuild app with solr config files:
oc start-build --from-dir . solr-blog

After update docker file or s2i scripts

./ && \
docker push alacambra/openshift-solr:8.2.0 && \
oc import-image s2i-solr --from="alacambra/openshift-solr:8.2.0" --confirm && \
oc start-build --from-dir ./solr/ solr-blog

Send a query request

Response body: