Last active
September 18, 2017 10:34
-
-
Save makuk66/b006fe688f4861e0a31e6a14104125f0 to your computer and use it in GitHub Desktop.
Create a docker solr image for RCs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Script to try out RCs. It's not exactly the same as the full docker-solr | |
# Dockerfiles, but close. | |
set -euo pipefail | |
# URL from command-line. | |
# If you want to find the latest, go to https://dist.apache.org/repos/dist/dev/lucene/ and click down to the solr tar.gz | |
solr_url=${1:-https://dist.apache.org/repos/dist/dev/lucene/lucene-solr-7.0.0-RC3-rev3ba304b29825a94249c5145b3f5061e87b87d8f8/solr/solr-7.0.0.tgz} | |
filename=$(basename "$solr_url") | |
if [[ ! -f "$filename" ]]; then | |
curl --remote-name "$solr_url" | |
fi | |
shasum -b "$filename" | |
rm -fr docker-solr-tmp | |
git clone https://github.com/docker-solr/docker-solr.git docker-solr-tmp | |
cd docker-solr-tmp | |
mkdir docker | |
cp "../$filename" docker/ | |
cp -r scripts docker/ | |
cd docker | |
cat > Dockerfile <<EOM | |
FROM openjdk:8-jre | |
MAINTAINER Martijn Koster "[email protected]" | |
RUN apt-get update && \ | |
apt-get -y install lsof procps && \ | |
rm -rf /var/lib/apt/lists/* | |
ENV SOLR_USER="solr" \ | |
SOLR_UID="8983" \ | |
SOLR_GROUP="solr" \ | |
SOLR_GID="8983" \ | |
SOLR_VERSION="\$REPLACE_SOLR_VERSION" \ | |
PATH="/opt/solr/bin:/opt/docker-solr/scripts:\$PATH" | |
RUN groupadd -r --gid \$SOLR_UID \$SOLR_GROUP && \ | |
useradd -r --uid \$SOLR_UID --gid \$SOLR_GID \$SOLR_USER | |
COPY $filename /tmp/$filename | |
RUN mkdir -p /opt/solr && \ | |
ls -l /tmp && \ | |
tar -C /opt/solr --extract --file /tmp/$filename --strip-components=1 && \ | |
mkdir -p /opt/solr/server/solr/lib /opt/solr/server/solr/mycores /opt/solr/server/logs /docker-entrypoint-initdb.d /opt/docker-solr && \ | |
sed -i -e 's/"\$(whoami)" == "root"/$(id -u) == 0/' /opt/solr/bin/solr && \ | |
sed -i -e 's/lsof -PniTCP:/lsof -t -PniTCP:/' /opt/solr/bin/solr && \ | |
sed -i -e 's/#SOLR_PORT=8983/SOLR_PORT=8983/' /opt/solr/bin/solr.in.sh && \ | |
sed -i -e '/-Dsolr.clustering.enabled=true/ a SOLR_OPTS="\$SOLR_OPTS -Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=60"' /opt/solr/bin/solr.in.sh && \ | |
chown -R \$SOLR_USER:\$SOLR_USER /opt/solr && \ | |
rm /tmp/$filename | |
COPY scripts /opt/docker-solr/scripts | |
RUN chown -R \$SOLR_USER:\$SOLR_GROUP /opt/docker-solr | |
EXPOSE 8983 | |
WORKDIR /opt/solr | |
USER \$SOLR_USER | |
ENTRYPOINT ["docker-entrypoint.sh"] | |
CMD ["solr-foreground"] | |
EOM | |
TAG=docker-tmp | |
docker build -t "$TAG" . | |
echo "now run: docker run -it -p 8983:8983 $TAG solr-demo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment