|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | + |
| 17 | +FROM eclipse-temurin:25-jre-noble |
| 18 | + |
| 19 | +ARG SOLR_VERSION="10.0.0" |
| 20 | +# empty for the full distribution, "-slim" for the slim distribution |
| 21 | +ARG SOLR_DIST="-slim" |
| 22 | +ARG SOLR_SHA512="18817965956567405f5788f391ac94b88777ecb2ebb0ee11ef88e6bd117508461b735f926cdf2e138b9ffb48c51700c104f3f20722f85d4e5bc8c9f790d16ef1" |
| 23 | +ARG SOLR_KEYS="EDF961FF03E647F9CA8A9C2C758051CCA3A13A7F" |
| 24 | + |
| 25 | +# Override the default solr download location with a preferred mirror, e.g.: |
| 26 | +# docker build -t mine --build-arg SOLR_DOWNLOAD_SERVER=https://downloads.apache.org/solr/solr . |
| 27 | +# This server must support downloading at: ${SOLR_DOWNLOAD_SERVER}/${SOLR_VERSION}/solr-${SOLR_VERSION}(-slim).tgz(.asc) |
| 28 | +ARG SOLR_DOWNLOAD_SERVER="https://www.apache.org/dyn/closer.lua?action=download&filename=/solr/solr" |
| 29 | + |
| 30 | +RUN set -ex; \ |
| 31 | + apt-get update; \ |
| 32 | + apt-get -y --no-install-recommends install wget gpg gnupg dirmngr; \ |
| 33 | + rm -rf /var/lib/apt/lists/*; \ |
| 34 | + export SOLR_BINARY="solr-$SOLR_VERSION$SOLR_DIST.tgz"; \ |
| 35 | + MAX_REDIRECTS=3; \ |
| 36 | + case "${SOLR_DOWNLOAD_SERVER}" in \ |
| 37 | + (*"apache.org"*);; \ |
| 38 | + (*) \ |
| 39 | + # If a non-ASF URL is provided, allow more redirects and skip GPG step. |
| 40 | + MAX_REDIRECTS=4 && \ |
| 41 | + SKIP_GPG_CHECK=true;; \ |
| 42 | + esac; \ |
| 43 | + export DOWNLOAD_URL="$SOLR_DOWNLOAD_SERVER/$SOLR_VERSION/$SOLR_BINARY"; \ |
| 44 | + echo "downloading $DOWNLOAD_URL"; \ |
| 45 | + if ! wget -t 10 --max-redirect $MAX_REDIRECTS --retry-connrefused -nv "$DOWNLOAD_URL" -O "/opt/$SOLR_BINARY"; then rm -f "/opt/$SOLR_BINARY"; fi; \ |
| 46 | + if [ ! -f "/opt/$SOLR_BINARY" ]; then echo "failed download attempt for $SOLR_BINARY"; exit 1; fi; \ |
| 47 | + echo "$SOLR_SHA512 */opt/$SOLR_BINARY" | sha512sum -c -; \ |
| 48 | + if [ -z "$SKIP_GPG_CHECK" ]; then \ |
| 49 | + # Setup GPG \ |
| 50 | + export GNUPGHOME="/tmp/gnupg_home"; \ |
| 51 | + mkdir -p "$GNUPGHOME"; \ |
| 52 | + chmod 700 "$GNUPGHOME"; \ |
| 53 | + echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf"; \ |
| 54 | + if [ -n "$SOLR_KEYS" ]; then \ |
| 55 | + # Install all Solr GPG Keys to start |
| 56 | + wget -nv "https://downloads.apache.org/solr/KEYS" -O- | \ |
| 57 | + gpg --batch --import --key-origin 'url,https://downloads.apache.org/solr/KEYS'; \ |
| 58 | + # Save just the release key |
| 59 | + release_keys="$(gpg --batch --export -a ${SOLR_KEYS})"; \ |
| 60 | + rm -rf "$GNUPGHOME"/*; \ |
| 61 | + echo "${release_keys}" | gpg --batch --import; \ |
| 62 | + fi; \ |
| 63 | + # Do GPG Checks |
| 64 | + echo "downloading $DOWNLOAD_URL.asc"; \ |
| 65 | + wget -nv "$DOWNLOAD_URL.asc" -O "/opt/$SOLR_BINARY.asc"; \ |
| 66 | + (>&2 ls -l "/opt/$SOLR_BINARY" "/opt/$SOLR_BINARY.asc"); \ |
| 67 | + gpg --batch --verify "/opt/$SOLR_BINARY.asc" "/opt/$SOLR_BINARY"; \ |
| 68 | + # Cleanup GPG |
| 69 | + { command -v gpgconf; gpgconf --kill all || :; }; \ |
| 70 | + rm -r "$GNUPGHOME"; \ |
| 71 | + else \ |
| 72 | + echo "Skipping GPG validation due to non-Apache build"; \ |
| 73 | + fi; \ |
| 74 | + tar -C /opt --extract --preserve-permissions --file "/opt/$SOLR_BINARY"; \ |
| 75 | + rm "/opt/$SOLR_BINARY"*; \ |
| 76 | + apt-get -y remove gpg dirmngr && apt-get -y autoremove; |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +LABEL org.opencontainers.image.title="Apache Solr" |
| 81 | +LABEL org.opencontainers.image.description="Solr is the blazing-fast, open source, multi-modal search platform built on Apache Lucene. It powers full-text, vector, and geospatial search at many of the world's largest organizations." |
| 82 | +LABEL org.opencontainers.image.authors="The Apache Solr Project" |
| 83 | +LABEL org.opencontainers.image.url="https://solr.apache.org" |
| 84 | +LABEL org.opencontainers.image.source="https://github.com/apache/solr" |
| 85 | +LABEL org.opencontainers.image.documentation="https://solr.apache.org/guide/" |
| 86 | +LABEL org.opencontainers.image.version="${SOLR_VERSION}" |
| 87 | +LABEL org.opencontainers.image.licenses="Apache-2.0" |
| 88 | + |
| 89 | +ENV SOLR_USER="solr" \ |
| 90 | + SOLR_UID="8983" \ |
| 91 | + SOLR_GROUP="solr" \ |
| 92 | + SOLR_GID="8983" \ |
| 93 | + PATH="/opt/solr/bin:/opt/solr/docker/scripts:/opt/solr/cross-dc-manager/bin:$PATH" \ |
| 94 | + SOLR_INCLUDE=/etc/default/solr.in.sh \ |
| 95 | + SOLR_HOME=/var/solr/data \ |
| 96 | + SOLR_PID_DIR=/var/solr \ |
| 97 | + SOLR_LOGS_DIR=/var/solr/logs \ |
| 98 | + LOG4J_PROPS=/var/solr/log4j2.xml \ |
| 99 | + SOLR_HOST_BIND="0.0.0.0" \ |
| 100 | + SOLR_ZOOKEEPER_EMBEDDED_HOST="0.0.0.0" |
| 101 | + |
| 102 | +RUN set -ex; \ |
| 103 | + groupadd -r --gid "$SOLR_GID" "$SOLR_GROUP"; \ |
| 104 | + useradd -r --uid "$SOLR_UID" --gid "$SOLR_GID" "$SOLR_USER" |
| 105 | + |
| 106 | +# add symlink to /opt/solr, remove what we don't want. |
| 107 | +# Remove the Dockerfile because it might not represent the dockerfile that was used to generate the image. |
| 108 | +RUN set -ex; \ |
| 109 | + (cd /opt; ln -s solr-*/ solr); \ |
| 110 | + rm -Rf /opt/solr/docs /opt/solr/docker/Dockerfile; |
| 111 | + |
| 112 | +RUN set -ex; \ |
| 113 | + mkdir -p /opt/solr/server/solr/lib /docker-entrypoint-initdb.d; \ |
| 114 | + cp /opt/solr/bin/solr.in.sh /etc/default/solr.in.sh; \ |
| 115 | + mv /opt/solr/bin/solr.in.sh /opt/solr/bin/solr.in.sh.orig; \ |
| 116 | + mv /opt/solr/bin/solr.in.cmd /opt/solr/bin/solr.in.cmd.orig; \ |
| 117 | + chmod 0664 /etc/default/solr.in.sh; \ |
| 118 | + mkdir -p -m0770 /var/solr; \ |
| 119 | + chown -R "$SOLR_USER:0" /var/solr; |
| 120 | + |
| 121 | +RUN set -ex; \ |
| 122 | + apt-get update; \ |
| 123 | + apt-get -y --no-install-recommends install curl acl lsof procps wget netcat-openbsd gosu tini jattach; \ |
| 124 | + rm -rf /var/lib/apt/lists/*; |
| 125 | + |
| 126 | +VOLUME /var/solr |
| 127 | +EXPOSE 8983 |
| 128 | +WORKDIR /opt/solr |
| 129 | +USER $SOLR_UID |
| 130 | + |
| 131 | +ENTRYPOINT ["docker-entrypoint.sh"] |
| 132 | +CMD ["solr-foreground"] |
0 commit comments