Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15891: Shrink Solr image, use default tarball file permissions (#498)

Houston Putman569000722506
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ebd055d0c66..7f042e822c6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -235,6 +235,8 @@ Build
* SOLR-15867: Make the gradle build ready for 9.0 release (janhoy, Houston Putman, Dawid Weiss)
+* SOLR-15891: The Solr Docker image uses the default file permissions from the tarball artifact (Houston Putman, janhoy)
+
Other Changes
----------------------
* SOLR-15603: Add an option to activate Gradle build cache, build task cleanups (Alexis Tual, Dawid Weiss)
diff --git a/solr/docker/build.gradle b/solr/docker/build.gradle
index 92cbb260674..2a7ee3f1129 100644
--- a/solr/docker/build.gradle
+++ b/solr/docker/build.gradle
@@ -28,6 +28,7 @@ def dockerImageRepo = propertyOrEnvOrDefault("solr.docker.imageRepo", "SOLR_DOCK
def dockerImageTag = propertyOrEnvOrDefault("solr.docker.imageTag", "SOLR_DOCKER_IMAGE_TAG", "${version}")
def dockerImageName = propertyOrEnvOrDefault("solr.docker.imageName", "SOLR_DOCKER_IMAGE_NAME", "${dockerImageRepo}:${dockerImageTag}")
def baseDockerImage = propertyOrEnvOrDefault("solr.docker.baseImage", "SOLR_DOCKER_BASE_IMAGE", 'openjdk:11-jre-slim')
+def officialDockerImageName = propertyOrEnvOrDefault("solr.docker.imageName", "SOLR_DOCKER_IMAGE_NAME", "${dockerImageRepo}-official:${dockerImageTag}")
def releaseGpgFingerprint = propertyOrDefault('signing.gnupg.keyName',propertyOrDefault('signing.keyId',''));
@@ -398,9 +399,16 @@ task testBuildDockerfileOfficial(type: Copy) {
"--iidfile", imageIdFileOfficial,
'--build-arg', "SOLR_CLOSER_URL=http://mock-solr-dl-server:9876/solr-${version}.tgz",
'--build-arg', "SOLR_ARCHIVE_URL=http://mock-solr-dl-server:9876/solr-${version}.tgz",
+ '--tag', officialDockerImageName,
'-'
}
-
+
+ def officialDockerImageId = file(imageIdFileOfficial).text
+
+ // Print information on the image after it has been created
+ project.logger.lifecycle("\"Official\" Solr Docker Image Tagged")
+ project.logger.lifecycle("\tID: \t$officialDockerImageId")
+ project.logger.lifecycle("\tTag: \t$officialDockerImageName")
} finally {
// Try to shut down our mock httpd server....
if (mockServerIdFile.exists()) {
@@ -429,7 +437,7 @@ task testBuildDockerfileOfficial(type: Copy) {
task testDockerfileOfficial(type: TestDockerImageTask, dependsOn: configurations.dockerOfficialSmokeCheckImage) {
description = 'Smoke Test Solr docker image built from Dockerfile.official'
-
+
idFile = file(imageIdFileOfficial)
outputDir = file("$smokeTestOfficial/test-results")
@@ -446,6 +454,10 @@ abstract class TestDockerImageTask extends DefaultTask {
@InputFile
abstract public RegularFileProperty getIdFile()
+ // Ensure that the docker image is re-tested if the shared test library changes
+ @InputFile
+ File sharedTestLibraryFile = project.file("tests/shared.sh")
+
@InputDirectory
File sourceDir = project.file("tests/cases")
diff --git a/solr/docker/templates/Dockerfile.body.template b/solr/docker/templates/Dockerfile.body.template
index 110a7a93b32..0f462d2287f 100644
--- a/solr/docker/templates/Dockerfile.body.template
+++ b/solr/docker/templates/Dockerfile.body.template
@@ -27,16 +27,15 @@
#-#
# remove what we don't want; ensure permissions are right
+# In the header templates, all solr files/directories are set to 0644 permissions, so we need to update that.
# TODO; arguably these permissions should have been set correctly previously in the TAR
RUN set -ex; \
(cd /opt; ln -s solr-*/ solr); \
- rm -Rf /opt/solr/docs /opt/solr/dist/solr-solrj-*.jar /opt/solr/dist/solrj-lib /opt/solr/dist/solr-core-*.jar; \
- 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-scripts
+ rm -Rf /opt/solr/docs /opt/solr/dist/solr-solrj-*.jar /opt/solr/dist/solrj-lib /opt/solr/dist/solr-core-*.jar;
-LABEL maintainer="The Apache Lucene/Solr Project"
-LABEL repository="https://github.com/apache/lucene-solr"
+LABEL maintainer="The Apache Solr Project"
+LABEL url="https://solr.apache.org"
+LABEL repository="https://github.com/apache/solr"
RUN set -ex; \
apt-get update; \
diff --git a/solr/docker/templates/Dockerfile.official.header.template b/solr/docker/templates/Dockerfile.official.header.template
index a91d088b692..a8de667e479 100644
--- a/solr/docker/templates/Dockerfile.official.header.template
+++ b/solr/docker/templates/Dockerfile.official.header.template
@@ -90,5 +90,5 @@ RUN set -ex; \
fi; \
{ command -v gpgconf; gpgconf --kill all || :; }; \
rm -r "$GNUPGHOME"; \
- tar -C /opt --extract --file "/opt/solr-$SOLR_VERSION.tgz";
+ tar -C /opt --extract --preserve-permissions --file "/opt/solr-$SOLR_VERSION.tgz";
diff --git a/solr/docker/tests/shared.sh b/solr/docker/tests/shared.sh
index 8ef98094676..a07661c4999 100755
--- a/solr/docker/tests/shared.sh
+++ b/solr/docker/tests/shared.sh
@@ -113,8 +113,8 @@ function prepare_dir_to_mount {
# If you can't use setfacl (eg on macOS), you'll have to chown the directory to 8983, or apply world
# write permissions.
if ! command -v setfacl &> /dev/null; then
- echo "Test case requires the 'setfacl' command but it can not be found"
- exit 1
+ echo "Test case requires the 'setfacl' command but it can not be found. Will set the directory to have read/write all permissions"
+ chmod a+rwx "$folder"
fi
if ! setfacl -m "u:$userid:rwx" "$folder"; then
echo "Unable to add permissions for $userid to '$folder'"
diff --git a/solr/packaging/build.gradle b/solr/packaging/build.gradle
index e2f86d1114b..c919b562f7a 100644
--- a/solr/packaging/build.gradle
+++ b/solr/packaging/build.gradle
@@ -92,19 +92,6 @@ distributions {
contents {
// TODO: This is missing module README files, as compared to 8x
- // Manually correct posix permissions (matters when packaging on Windows).
- filesMatching([
- "**/*.sh",
- "**/bin/post",
- "**/bin/postlogs",
- "**/bin/solr",
- "**/bin/init.d/solr",
- "**/bin/solr-exporter",
- "**/docker/scripts/*",
- ]) { copy ->
- copy.setMode(0755)
- }
-
from(project(":solr").projectDir, {
include "bin/**"
include "licenses/**"
@@ -141,8 +128,25 @@ distributions {
from(configurations.docker, {
into "docker"
+ filesMatching([
+ "scripts/**",
+ ]) { copy ->
+ copy.setMode(0755)
+ }
})
+ // Manually correct posix permissions (matters when packaging on Windows).
+ filesMatching([
+ "**/*.sh",
+ "**/bin/post",
+ "**/bin/postlogs",
+ "**/bin/solr",
+ "**/bin/init.d/solr",
+ "**/bin/solr-exporter",
+ ]) { copy ->
+ copy.setMode(0755)
+ }
+
}
}
}
@@ -163,4 +167,4 @@ distTar {
compression = Compression.GZIP
}
-assemble.dependsOn installDist
\ No newline at end of file
+assemble.dependsOn installDist