# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #-# #-# This template is used as the header of "official" Apache Solr Dockerfiles. #-# #-# ####################################################################### #-# FROM _REPLACE_BASE_IMAGE_ ARG SOLR_VERSION="_REPLACE_SOLR_VERSION_" # empty for the full distribution, "-slim" for the slim distribution ARG SOLR_DIST="_REPLACE_SOLR_DIST_" ARG SOLR_SHA512="_REPLACE_SOLR_TGZ_SHA_" ARG SOLR_KEYS="_REPLACE_RELEASE_MANAGER_GPG_FINGERPRINT_" # Override the default solr download location with a preferred mirror, e.g.: # docker build -t mine --build-arg SOLR_DOWNLOAD_SERVER=https://downloads.apache.org/solr/solr . # This server must support downloading at: ${SOLR_DOWNLOAD_SERVER}/${SOLR_VERSION}/solr-${SOLR_VERSION}(-slim).tgz(.asc) ARG SOLR_DOWNLOAD_SERVER="https://www.apache.org/dyn/closer.lua?action=download&filename=/solr/solr" RUN set -ex; \ apt-get update; \ apt-get -y --no-install-recommends install wget gpg gnupg dirmngr; \ rm -rf /var/lib/apt/lists/*; \ export SOLR_BINARY="solr-$SOLR_VERSION$SOLR_DIST.tgz"; \ MAX_REDIRECTS=3; \ case "${SOLR_DOWNLOAD_SERVER}" in \ (*"apache.org"*);; \ (*) \ # If a non-ASF URL is provided, allow more redirects and skip GPG step. MAX_REDIRECTS=4 && \ SKIP_GPG_CHECK=true;; \ esac; \ export DOWNLOAD_URL="$SOLR_DOWNLOAD_SERVER/$SOLR_VERSION/$SOLR_BINARY"; \ echo "downloading $DOWNLOAD_URL"; \ if ! wget -t 10 --max-redirect $MAX_REDIRECTS --retry-connrefused -nv "$DOWNLOAD_URL" -O "/opt/$SOLR_BINARY"; then rm -f "/opt/$SOLR_BINARY"; fi; \ if [ ! -f "/opt/$SOLR_BINARY" ]; then echo "failed download attempt for $SOLR_BINARY"; exit 1; fi; \ echo "$SOLR_SHA512 */opt/$SOLR_BINARY" | sha512sum -c -; \ if [ -z "$SKIP_GPG_CHECK" ]; then \ # Setup GPG \ export GNUPGHOME="/tmp/gnupg_home"; \ mkdir -p "$GNUPGHOME"; \ chmod 700 "$GNUPGHOME"; \ echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf"; \ if [ -n "$SOLR_KEYS" ]; then \ # Install all Solr GPG Keys to start wget -nv "https://downloads.apache.org/solr/KEYS" -O- | \ gpg --batch --import --key-origin 'url,https://downloads.apache.org/solr/KEYS'; \ # Save just the release key release_keys="$(gpg --batch --export -a ${SOLR_KEYS})"; \ rm -rf "$GNUPGHOME"/*; \ echo "${release_keys}" | gpg --batch --import; \ fi; \ # Do GPG Checks echo "downloading $DOWNLOAD_URL.asc"; \ wget -nv "$DOWNLOAD_URL.asc" -O "/opt/$SOLR_BINARY.asc"; \ (>&2 ls -l "/opt/$SOLR_BINARY" "/opt/$SOLR_BINARY.asc"); \ gpg --batch --verify "/opt/$SOLR_BINARY.asc" "/opt/$SOLR_BINARY"; \ # Cleanup GPG { command -v gpgconf; gpgconf --kill all || :; }; \ rm -r "$GNUPGHOME"; \ else \ echo "Skipping GPG validation due to non-Apache build"; \ fi; \ tar -C /opt --extract --preserve-permissions --file "/opt/$SOLR_BINARY"; \ rm "/opt/$SOLR_BINARY"*; \ apt-get -y remove gpg dirmngr && apt-get -y autoremove;