Skip to content

Commit

Permalink
Merge pull request #951 from uselagoon/solr-9
Browse files Browse the repository at this point in the history
Add solr-9 compatible images
  • Loading branch information
tobybellwood committed Mar 19, 2024
2 parents 8d79f2f + fea0e0e commit 6966fbd
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ versioned-images := php-8.1-fpm \
node-20-cli \
solr-8 \
solr-8-drupal \
solr-9 \
solr-9-drupal \
postgres-12 \
postgres-12-drupal \
postgres-13 \
Expand Down Expand Up @@ -302,8 +304,9 @@ build/varnish-6-drupal build/varnish-6-persistent: build/varnish-6
build/varnish-6-persistent-drupal: build/varnish-6-drupal
build/varnish-7-drupal build/varnish-7-persistent: build/varnish-7
build/varnish-7-persistent-drupal: build/varnish-7-drupal
build/solr-8: build/commons
build/solr-8 build/solr-9: build/commons
build/solr-8-drupal: build/solr-8
build/solr-9-drupal: build/solr-9
build/mariadb-10.4 build/mariadb-10.5 build/mariadb-10.6 build/mariadb-10.11: build/commons
build/mariadb-10.4-drupal: build/mariadb-10.4
build/mariadb-10.5-drupal: build/mariadb-10.5
Expand Down
3 changes: 3 additions & 0 deletions images/solr-drupal/8.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/solr-8

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

COPY drupal-4.1.1-solr-8.x-0 /solr-conf

CMD ["solr-precreate", "drupal", "/solr-conf"]
16 changes: 16 additions & 0 deletions images/solr-drupal/9.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as jumpstart

ADD https://git.drupalcode.org/project/search_api_solr.git#4.3.2 /search_api_solr

ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/solr-9

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

COPY --from=jumpstart /search_api_solr/jump-start/solr9/config-set /solr-conf/conf
ENV SOLR_INSTALL_DIR=/opt/solr
RUN mkdir -p /var/solr/data

CMD ["solr-precreate", "drupal", "/solr-conf"]
78 changes: 78 additions & 0 deletions images/solr/9.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons
FROM solr:9.5.0

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=solr
ENV SOLR_DATA_HOME=/var/solr
ENV SOLR_LOGS_DIR=/opt/solr/server/logs

ARG LAGOON_VERSION
ENV LAGOON_VERSION=$LAGOON_VERSION

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/
COPY --from=commons /home/.bashrc /home/.bashrc

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# we need root for the fix-permissions to work
USER root

RUN apt-get -y update \
&& apt-get -y install \
busybox \
curl \
zip \
&& rm -rf /var/lib/apt/lists/*

# Mitigation for CVE-2021-45046 and CVE-2021-44228 - not needed in log4j-core 2.16.0
# RUN zip -q -d /opt/solr-8.10.1/server/lib/ext/log4j-core-2.14.1.jar org/apache/logging/log4j/core/lookup/JndiLookup.class \
# && zip -q -d /opt/solr-8.10.1/contrib/prometheus-exporter/lib/log4j-core-2.14.1.jar org/apache/logging/log4j/core/lookup/JndiLookup.class

RUN architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& curl -sL https://github.com/krallin/tini/releases/download/v0.19.0/tini-${architecture} -o /sbin/tini && chmod a+x /sbin/tini

# needed to fix dash upgrade - man files are removed from slim images
RUN set -x \
&& mkdir -p /usr/share/man/man1 \
&& touch /usr/share/man/man1/sh.distrib.1.gz

# replace default dash shell with bash to allow for bashisms
RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

RUN mkdir -p /var/solr /opt/solr/server/logs /opt/solr/server/solr
RUN fix-permissions /var/solr \
&& chown solr:solr /var/solr /opt/solr/server/logs /opt/solr/server/solr \
&& fix-permissions /opt/solr/server/logs \
&& fix-permissions /opt/solr/server/solr

COPY solr-recreate.sh /opt/solr/docker/scripts/solr-recreate
RUN chmod 775 /opt/solr/docker/scripts/solr-recreate

# solr really doesn't like to be run as root, so we define the default user agin
USER solr

ENV SOLR_OPTS="-Dlog4j2.formatMsgNoLookups=true"

COPY 10-solr-port.sh /lagoon/entrypoints/
# currently, there is no smart upgrade path from 7 to 8 - no autoremediation etc
# and whilst sites may work, upgrading from 7 to 8, they won't work downgrading...
# COPY 20-solr-datadir.sh /lagoon/entrypoints/

# Define Volume so locally we get persistent cores
VOLUME /var/solr

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]

CMD ["solr-precreate", "mycore"]
19 changes: 15 additions & 4 deletions images/solr/solr-recreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@ set -e
echo "Executing $0" "$@"

if [[ "${VERBOSE:-}" == "yes" ]]; then
set -x
set -x
fi

if [ -d /opt/docker-solr/scripts ]; then
echo "Solr 8 scripts directory detected"
SCRIPTS_DIR=${SOLR8_SCRIPTS_DIR:-/opt/docker-solr/scripts}
elif [ -d /opt/solr/docker/scripts ]; then
echo "Solr 9 scripts directory detected"
SCRIPTS_DIR=${SOLR9_SCRIPTS_DIR:-/opt/solr/docker/scripts}
else
echo "No scripts directory detected"
exit 1
fi

# init script for handling an empty /var/solr
/opt/docker-solr/scripts/init-var-solr
$SCRIPTS_DIR/init-var-solr

# ensure that the target core directory is empty prior to recreation
rm -rf /var/solr/data/$1
echo "Removed $1 core prior to recreation"

# run the precreate-core script again to bring in any new config
/opt/docker-solr/scripts/precreate-core "$@"
$SCRIPTS_DIR/precreate-core "$@"

# set correct solr.lock.type for Lagoon
grep -rl solr.lock.type /var/solr/data/$1 | xargs sed -i '/solr.lock.type/ s/native/none/'
echo "solr.lock.type set for $1 core"
grep -r solr.lock.type /var/solr/data/$1

# the solr-recreate command only removes and recreates the cores, it doesn't start the solr process
echo "Please ensure that you run solr-foreground after this command as part of your CMD statement"
echo "Please ensure that you run solr-foreground after this command as part of your CMD statement"

0 comments on commit 6966fbd

Please sign in to comment.