This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 7694064fced SOLR-18032 Use SOLR_DOCKER_PLATFORM only for dockerPush 
command (#3973)
7694064fced is described below

commit 7694064fced5b4d649c87faa5e6c1765a6af306a
Author: Jan Høydahl <[email protected]>
AuthorDate: Mon Dec 22 23:05:56 2025 +0100

    SOLR-18032 Use SOLR_DOCKER_PLATFORM only for dockerPush command (#3973)
---
 dev-docs/gradle-help/docker.txt | 30 +++++----------------
 solr/docker/README.md           |  5 ++++
 solr/docker/build.gradle        | 58 +++++++----------------------------------
 3 files changed, 22 insertions(+), 71 deletions(-)

diff --git a/dev-docs/gradle-help/docker.txt b/dev-docs/gradle-help/docker.txt
index b691a3359b1..fa632a66505 100644
--- a/dev-docs/gradle-help/docker.txt
+++ b/dev-docs/gradle-help/docker.txt
@@ -26,19 +26,15 @@ Solr Distribution: (Either Full or Slim, the solr binary 
distribution to build t
    EnvVar: SOLR_DOCKER_DIST
    Gradle Property: -Psolr.docker.dist
 
-Docker Platforms: (Comma-separated list of target platforms)
-   Default: None (builds for current architecture only)
+Docker Platforms: (Comma-separated list of target platforms for dockerPush)
+   Default: None (pushes image built for current architecture)
    EnvVar: SOLR_DOCKER_PLATFORM
    Gradle Property: -Psolr.docker.platform
    Examples:
-     - "linux/amd64" (single platform - can be used with dockerBuild)
-     - "linux/arm64,linux/amd64" (multi-platform - only supported by 
dockerPush)
+     - "linux/amd64" (single platform)
+     - "linux/arm64,linux/amd64" (multi-platform)
 
-   Note: Multi-platform builds require Docker Buildx and are ONLY supported
-   by the dockerPush task. The dockerBuild task does not support 
multi-platform builds because
-   Docker cannot load multi-platform images into the local daemon. Use 
dockerPush to build and push
-   multi-platform images in a single step. You may need QEMU installed to run 
multi-platform
-   builds.
+   Note: This setting ONLY affects the dockerPush task
 
 Tagging and Pushing
 -------
@@ -78,10 +74,8 @@ Docker Image Name: (Use this to explicitly set a whole image 
name. If given, the
 Multi-Platform Builds
 -------
 
-To build a multi-platform Docker image, use the SOLR_DOCKER_PLATFORM 
environment variable or Gradle property.
-
-IMPORTANT: Multi-platform builds (with multiple platforms) are ONLY supported 
by dockerPush, not dockerBuild.
-This is because Docker cannot load multi-platform images into the local daemon.
+Multi-platform Docker builds are ONLY supported by the dockerPush task.
+The dockerBuild task always builds for your current local architecture.
 
 Prerequisites:
    - Docker Buildx must be installed (included with Docker Desktop and recent 
Docker Engine versions)
@@ -98,16 +92,6 @@ Using Gradle property:
 The dockerPush task will build and push the multi-platform image in a single 
step using Docker Buildx.
 The task will validate that a suitable builder exists and that it supports all 
requested platforms before building.
 
-Single-Platform Builds with Explicit Platform
---------------------------------------------------
-
-You can build for a specific platform and load it into your local Docker 
daemon:
-
-Build for a specific platform:
-   SOLR_DOCKER_PLATFORM=linux/arm64 ./gradlew dockerBuild
-
-This uses Docker Buildx with --load to make the image available locally for 
testing.
-
 Testing
 -------
 
diff --git a/solr/docker/README.md b/solr/docker/README.md
index 109fd18f979..747bc6b23a6 100644
--- a/solr/docker/README.md
+++ b/solr/docker/README.md
@@ -73,6 +73,11 @@ docker buildx build --platform linux/amd64,linux/arm64 -f 
solr-X.Y.Z/docker/Dock
 docker buildx build --platform linux/arm64 -f solr-X.Y.Z/docker/Dockerfile 
--tag myrepo/solr:X.Y.Z-arm64 --load - < solr-X.Y.Z.tgz
 ```
 
+**Note**: When building Docker images using Gradle tasks (`./gradlew 
dockerBuild`, `./gradlew dockerPush`),
+the `dockerBuild` task always builds for your current local architecture only. 
Multi-platform and
+single-platform targeting is only supported by the `dockerPush` task via the 
`SOLR_DOCKER_PLATFORM`
+environment variable or property `-Psolr.docker.platform`. See `./gradlew 
helpDocker` for details.
+
 Official Image Management
 ----
 
diff --git a/solr/docker/build.gradle b/solr/docker/build.gradle
index e5f07c6aac9..79e165d08a4 100644
--- a/solr/docker/build.gradle
+++ b/solr/docker/build.gradle
@@ -168,11 +168,6 @@ def getBuildxBuilderInfo = {
   return builderCheckOutput.toString()
 }
 
-// Helper method to validate Docker Buildx builder is available
-def validateBuildxBuilder = {
-  getBuildxBuilderInfo()
-}
-
 
 task assemblePackaging(type: Sync) {
   description = 'Assemble docker scripts and Dockerfile for Solr Packaging'
@@ -197,51 +192,21 @@ task dockerBuild() {
 
   // Ensure that the docker image is rebuilt on build-arg changes or changes 
in the docker context
   inputs.properties([
-          baseDockerImage: baseDockerImage,
-          dockerImagePlatforms: dockerImagePlatforms
+          baseDockerImage: baseDockerImage
   ])
-  var solrTgzConfiguration = getSolrTgzConfiguration()
+  var solrTgzConfiguration = isImageSlim() ? configurations.solrSlimTgz : 
configurations.solrFullTgz
   inputs.files(solrTgzConfiguration)
   inputs.property("isSlimImage", isImageSlim())
-  inputs.property("isMultiPlatform", isMultiPlatform())
   dependsOn(solrTgzConfiguration)
 
   doLast {
-    def platformValue = 
inputs.properties.dockerImagePlatforms.toString().trim()
-    validatePlatformFormat(platformValue)
-    def useSinglePlatform = !platformValue.isEmpty() && 
!platformValue.contains(',')
-
-    // Multi-platform builds are not supported by dockerBuild, only by 
dockerPush
-    if (isMultiPlatform()) {
-      throw new GradleException("Multi-platform builds (SOLR_DOCKER_PLATFORM 
with multiple platforms) are not supported by dockerBuild.\n" +
-              "Please use 'dockerPush' instead, which will build and push the 
multi-platform image in a single step.\n" +
-              "Example: SOLR_DOCKER_PLATFORM=linux/arm64,linux/amd64 ./gradlew 
dockerPush")
-    }
-
-    if (useSinglePlatform) {
-      // Single-platform build with explicit platform using buildx
-      validateBuildxBuilder()
-
-      exec {
-        standardInput = solrTgzConfiguration.singleFile.newDataInputStream()
-        commandLine "docker", "buildx", "build",
-                "-f", "solr-${ -> project.version 
}${dockerImageDistSuffix}/docker/Dockerfile",
-                "--platform", platformValue,
-                "--build-arg", "BASE_IMAGE=${ -> 
inputs.properties.baseDockerImage}",
-                "--iidfile", imageIdFile,
-                "--load",
-                "-"
-      }
-    } else {
-      // Standard build for current architecture
-      exec {
-        standardInput = solrTgzConfiguration.singleFile.newDataInputStream()
-        commandLine "docker", "build",
-                "-f", "solr-${ -> project.version 
}${dockerImageDistSuffix}/docker/Dockerfile",
-                "--iidfile", imageIdFile,
-                "--build-arg", "BASE_IMAGE=${ -> 
inputs.properties.baseDockerImage}",
-                "-"
-      }
+    exec {
+      standardInput = solrTgzConfiguration.singleFile.newDataInputStream()
+      commandLine "docker", "build",
+              "-f", "solr-${ -> project.version 
}${dockerImageDistSuffix}/docker/Dockerfile",
+              "--iidfile", imageIdFile,
+              "--build-arg", "BASE_IMAGE=${ -> 
inputs.properties.baseDockerImage}",
+              "-"
     }
   }
 
@@ -249,13 +214,10 @@ task dockerBuild() {
   doLast {
     def dockerImageId = file(imageIdFile).text
     project.logger.lifecycle("Solr Docker Image Created")
-    project.logger.lifecycle("\tID/Ref: \t${ -> dockerImageId }")
+    project.logger.lifecycle("\tID: \t${ -> dockerImageId }")
     project.logger.lifecycle("\tBase Image: \t${ -> baseDockerImage }")
     project.logger.lifecycle("\tSolr Version: \t${ -> project.version }")
     project.logger.lifecycle("\tSolr Distribution: \t${isImageSlim() ? "Slim" 
: "Full"}")
-    if (!dockerImagePlatforms.isEmpty()) {
-      project.logger.lifecycle("\tPlatforms: \t${ -> dockerImagePlatforms }")
-    }
   }
 
   outputs.files(imageIdFile)

Reply via email to