Apache Solr open-source search software
SOLR-15322: Solr releases now contain everything needed to build runable docker images
Chris Hostettere4dc0334d5cd
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b3aea0596eb..e401423c633 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -110,6 +110,8 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)This doesn't work in SolrCloud (but may someday). QEC no longer supports a config file inthe data dir. (David Smiley)+* SOLR-15322: Solr releases now contain everything needed to build runable docker images (Houston Putman, hossman)+Other Changes----------------------* SOLR-14656: Autoscaling framework removed (Ishan Chattopadhyaya, noble, Ilan Ginzburg)diff --git a/solr/docker/Dockerfile b/solr/docker/Dockerfileindex 9d82c367523..443a0eb9cec 100644--- a/solr/docker/Dockerfile+++ b/solr/docker/Dockerfile@@ -1,19 +1,35 @@+# This file can be used to build an (unofficial) Docker image of Apache Solr.+#+# The primary purpose of this file, is for use by Solr developers, with a java/gradle development env, who+# wish to build customized -- or "patched" docker images of Solr. For this type of usecase, this file+# will be used automatically by gradle to build docker images from your local src.+# Example:+# ./gradlew dockerBuild+#+# For most Solr users, using this Dockerfile is not recommended: pre-built docker images of Solr are+# available at https://hub.docker.com/_/solr -- however this file can be used to build docker images from+# a Solr release artifact -- either from a remote TGZ file, or from an TGZ artifact you have downloaded+# locally.+# Example:+# docker build -f solr-X.Y.Z/docker/Dockerfile https://www.apache.org/dyn/closer.lua/solr/X.Y.Z/solr-X.Y.Z.tgz+# Example:+# docker build -f solr-X.Y.Z/docker/Dockerfile - < solr-X.Y.Z.tgz++ARG BASE_IMAGE=openjdk:11-jre-slimFROM $BASE_IMAGE as input-ARG SOLR_VERSION-# ADD extracts tgz !-ADD /releases/solr-$SOLR_VERSION.tgz /opt/-COPY /scripts /scripts+COPY / /opt/# remove what we don't want; ensure permissions are right# TODO; arguably these permissions should have been set correctly previously in the TARRUN set -ex; \- rm -Rf /opt/solr-$SOLR_VERSION/docs /opt/solr-$SOLR_VERSION/dist/{solr-solrj-$SOLR_VERSION.jar,solrj-lib,solr-test-framework-$SOLR_VERSION.jar,test-framework}; \- find "/opt/solr-$SOLR_VERSION" -type d -print0 | xargs -0 chmod 0755; \- find "/opt/solr-$SOLR_VERSION" -type f -print0 | xargs -0 chmod 0644; \- chmod -R 0755 /scripts "/opt/solr-$SOLR_VERSION/bin" "/opt/solr-$SOLR_VERSION/contrib/prometheus-exporter/bin/solr-exporter" "/opt/solr-$SOLR_VERSION/server/scripts/cloud-scripts"+ (cd /opt; ln -s solr-*/ solr); \+ rm -Rf /opt/solr/docs /opt/solr/docker/Dockerfile /opt/solr/dist/{solr-solrj-*.jar,solrj-lib,solr-test-framework-*.jar,test-framework}; \+ find /opt/solr/ -type d -print0 | xargs -0 chmod 0755; \+ find /opt/solr/ -type f -print0 | xargs -0 chmod 0644; \+ chmod -R 0755 /opt/solr/docker/scripts /opt/solr/bin /opt/solr/contrib/prometheus-exporter/bin/solr-exporter /opt/solr/server/scripts/cloud-scriptsFROM $BASE_IMAGE@@ -35,7 +51,7 @@ ENV SOLR_USER="solr" \SOLR_UID="8983" \SOLR_GROUP="solr" \SOLR_GID="8983" \- PATH="/opt/solr/bin:/opt/docker-solr/scripts:/opt/solr/contrib/prometheus-exporter/bin:$PATH" \+ PATH="/opt/solr/bin:/opt/solr/docker/scripts:/opt/solr/contrib/prometheus-exporter/bin:$PATH" \SOLR_INCLUDE=/etc/default/solr.in.sh \SOLR_HOME=/var/solr/data \SOLR_PID_DIR=/var/solr \@@ -47,17 +63,9 @@ RUN set -ex; \groupadd -r --gid "$SOLR_GID" "$SOLR_GROUP"; \useradd -r --uid "$SOLR_UID" --gid "$SOLR_GID" "$SOLR_USER"-COPY --from=input scripts /opt/docker-solr/scripts--ARG SOLR_VERSION--# Used by solr-fg-ENV SOLR_VERSION $SOLR_VERSION--COPY --from=input /opt/solr-$SOLR_VERSION /opt/solr-$SOLR_VERSION+COPY --from=input /opt/ /opt/RUN set -ex; \- (cd /opt; ln -s "solr-$SOLR_VERSION" solr); \mkdir -p /opt/solr/server/solr/lib /docker-entrypoint-initdb.d; \cp /opt/solr/bin/solr.in.sh /etc/default/solr.in.sh; \mv /opt/solr/bin/solr.in.sh /opt/solr/bin/solr.in.sh.orig; \diff --git a/solr/docker/build.gradle b/solr/docker/build.gradleindex 305a50d62c2..4fd91178327 100644--- a/solr/docker/build.gradle+++ b/solr/docker/build.gradle@@ -30,64 +30,85 @@ def baseDockerImage = propertyOrEnvOrDefault("solr.docker.baseImage", "SOLR_DOCKdef githubUrlOrMirror = propertyOrEnvOrDefault("solr.docker.githubUrl", "SOLR_DOCKER_GITHUB_URL", 'github.com')// Build directory locations-def dockerBuildDistribution = "$buildDir/distributions"def imageIdFile = "$buildDir/image-id"configurations {packaging {canBeResolved = true}+ solrArtifacts {+ canBeResolved = true+ }+ dockerContext {+ canBeResolved = true+ }dockerImage {canBeResolved = true}}+ext {+ packagingDir = file("${buildDir}/packaging")+ dockerContextFile = "context.tgz"+ dockerContextPath = "${buildDir}/${dockerContextFile}"+}+dependencies {- packaging project(path: ":solr:packaging", configuration: 'archives')+ packaging files(packagingDir) {+ builtBy 'assemblePackaging'+ }++ solrArtifacts project(path: ":solr:packaging", configuration: 'archives')++ dockerContext files(dockerContextPath) {+ builtBy 'dockerContext'+ }dockerImage files(imageIdFile) {builtBy 'dockerBuild'}}-task dockerTar(type: Tar) {- group = 'Docker'- description = 'Package docker context to prepare for docker build'+task assemblePackaging(type: Sync) {+ description = 'Assemble docker scripts and Dockerfile for Solr Packaging'- dependsOn configurations.packaging- into('scripts') {- from file('scripts')- fileMode 755- }- into('releases') {- from configurations.packaging- include '*.tgz'- }- from file('Dockerfile')- destinationDirectory = file(dockerBuildDistribution)- extension 'tgz'- compression = Compression.GZIP+ from(projectDir, {+ include "Dockerfile"+ include "scripts/**"+ })++ into packagingDir+}++task dockerContext(type: Sync) {+ description = 'Sync Solr tgz to become docker context'++ from(configurations.solrArtifacts, {+ include "*.tgz"+ rename { file -> dockerContextFile }+ })++ into buildDir}-task dockerBuild(dependsOn: tasks.dockerTar) {+task dockerBuild(dependsOn: configurations.dockerContext) {group = 'Docker'description = 'Build Solr docker image'// Ensure that the docker image is rebuilt on build-arg changes or changes in the docker contextinputs.properties([baseDockerImage: baseDockerImage,- githubUrlOrMirror: githubUrlOrMirror,- version: version+ githubUrlOrMirror: githubUrlOrMirror])- inputs.dir(dockerBuildDistribution)+ inputs.files(dockerContextPath)doLast {exec {- standardInput = tasks.dockerTar.outputs.files.singleFile.newDataInputStream()+ standardInput = configurations.dockerContext.singleFile.newDataInputStream()commandLine "docker", "build",+ "-f", "solr-${version}/docker/Dockerfile","--iidfile", imageIdFile,"--build-arg", "BASE_IMAGE=${inputs.properties.baseDockerImage}",- "--build-arg", "SOLR_VERSION=${version}","--build-arg", "GITHUB_URL=${inputs.properties.githubUrlOrMirror}","-"}diff --git a/solr/docker/scripts/docker-entrypoint.sh b/solr/docker/scripts/docker-entrypoint.shindex 69738a9206d..1a6a3ee2833 100755--- a/solr/docker/scripts/docker-entrypoint.sh+++ b/solr/docker/scripts/docker-entrypoint.sh@@ -18,7 +18,7 @@ if ! [[ ${SOLR_PORT:-} =~ ^[0-9]+$ ]]; thenfi# Essential for running Solr-/opt/docker-solr/scripts/init-var-solr+init-var-solr# when invoked with e.g.: docker run solr -helpif [ "${1:0:1}" == '-' ]; then@@ -27,7 +27,7 @@ fi# execute command passed in as arguments.# The Dockerfile has specified the PATH to include-# /opt/solr/bin (for Solr) and /opt/docker-solr/scripts (for our scripts+# /opt/solr/bin (for Solr) and /opt/solr/docker (for docker-specific scripts# like solr-foreground, solr-create, solr-precreate, solr-demo).# Note: if you specify "solr", you'll typically want to add -f to run it in# the foreground.diff --git a/solr/docker/scripts/solr-create b/solr/docker/scripts/solr-createindex d523ce6ec56..dbd2181da5e 100755--- a/solr/docker/scripts/solr-create+++ b/solr/docker/scripts/solr-create@@ -15,7 +15,7 @@ if [[ "${VERBOSE:-}" == "yes" ]]; thenset -xfi-. /opt/docker-solr/scripts/run-initdb+run-initdb# solr uses "-c corename". Parse the arguments to determine the core name.CORE_NAME="$(diff --git a/solr/docker/scripts/solr-demo b/solr/docker/scripts/solr-demoindex 7d09d395a47..4217d7d12b6 100755--- a/solr/docker/scripts/solr-demo+++ b/solr/docker/scripts/solr-demo@@ -8,7 +8,7 @@ if [[ "${VERBOSE:-}" == "yes" ]]; thenset -xfi-. /opt/docker-solr/scripts/run-initdb+run-initdbCORE=demodiff --git a/solr/docker/scripts/solr-fg b/solr/docker/scripts/solr-fgindex cf433166a97..13d26234106 100755--- a/solr/docker/scripts/solr-fg+++ b/solr/docker/scripts/solr-fg@@ -7,7 +7,7 @@ if [[ "$VERBOSE" == "yes" ]]; thenset -xfi-echo "Starting Solr $SOLR_VERSION"+echo "Starting Solr"# determine TINI default. If it is already set, assume the user knows what they wantif [[ -z "${TINI:-}" ]]; thenif [[ "$$" == 1 ]]; thendiff --git a/solr/docker/scripts/solr-foreground b/solr/docker/scripts/solr-foregroundindex aa9fa682908..d91a8721ab0 100755--- a/solr/docker/scripts/solr-foreground+++ b/solr/docker/scripts/solr-foreground@@ -7,6 +7,6 @@ if [[ "$VERBOSE" == "yes" ]]; thenset -xfi-. /opt/docker-solr/scripts/run-initdb+run-initdbexec solr-fg "$@"diff --git a/solr/docker/scripts/solr-precreate b/solr/docker/scripts/solr-precreateindex 91d0a3dd89c..701dcd12894 100755--- a/solr/docker/scripts/solr-precreate+++ b/solr/docker/scripts/solr-precreate@@ -17,8 +17,8 @@ if [[ "${VERBOSE:-}" == "yes" ]]; thenset -xfi-. /opt/docker-solr/scripts/run-initdb+run-initdb-/opt/docker-solr/scripts/precreate-core "$@"+precreate-core "$@"exec solr-fgdiff --git a/solr/docker/scripts/start-local-solr b/solr/docker/scripts/start-local-solrindex 50edf13f600..309fc9443d5 100755--- a/solr/docker/scripts/start-local-solr+++ b/solr/docker/scripts/start-local-solr@@ -11,7 +11,7 @@ echo "Running solr in the background. Logs are in /var/solr/logs"SOLR_OPTS="-Djetty.host=${SOLR_LOCAL_HOST:-localhost}" solr startmax_try=${MAX_TRY:-12}wait_seconds=${WAIT_SECONDS:-5}-if ! /opt/docker-solr/scripts/wait-for-solr.sh --max-attempts "$max_try" --wait-seconds "$wait_seconds"; then+if ! wait-for-solr.sh --max-attempts "$max_try" --wait-seconds "$wait_seconds"; thenecho "Could not start Solr."if [ -f "/var/solr/logs/solr.log" ]; thenecho "Here is the log:"diff --git a/solr/docker/tests/shared.sh b/solr/docker/tests/shared.shindex 6b4e211fed2..49dcdae066c 100755--- a/solr/docker/tests/shared.sh+++ b/solr/docker/tests/shared.sh@@ -25,7 +25,7 @@ function wait_for_container_and_solr {printf '\nWaiting for Solr...\n'local status- status=$(docker exec "$container_name" /opt/docker-solr/scripts/wait-for-solr.sh --max-attempts 60 --wait-seconds 1)+ status=$(docker exec "$container_name" wait-for-solr.sh --max-attempts 60 --wait-seconds 1)# echo "Got status from Solr: $status"if ! grep -E -i -q 'Solr is running' <<<"$status"; thenecho "Solr did not start"diff --git a/solr/packaging/build.gradle b/solr/packaging/build.gradleindex f533b3fa247..1a15ce43d18 100644--- a/solr/packaging/build.gradle+++ b/solr/packaging/build.gradle@@ -39,6 +39,7 @@ configurations {exampleserverdocs+ docker}dependencies {@@ -68,6 +69,8 @@ dependencies {// Copy files from documentation outputdocs project(path: ':solr:documentation', configuration: 'minimalSite')++ docker project(path: ':solr:docker', configuration: 'packaging')}distributions {@@ -84,6 +87,7 @@ distributions {"**/bin/solr","**/bin/init.d/solr","**/bin/solr-exporter",+ "**/docker/scripts/*",]) { copy ->copy.setMode(0755)}@@ -129,6 +133,11 @@ distributions {from(configurations.docs, {into "docs"})++ from(configurations.docker, {+ into "docker"+ })+}}}