From 096400de51be5447b1ac36ca877b6844d1ff366d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Mon, 22 Dec 2025 21:27:01 +0100 Subject: [PATCH 1/2] SOLR-18032 Use SOLR_DOCKER_PLATFORM only for dockerPush command --- dev-docs/gradle-help/docker.txt | 31 +++++------------- solr/docker/README.md | 5 +++ solr/docker/build.gradle | 58 ++++++--------------------------- 3 files changed, 24 insertions(+), 70 deletions(-) diff --git a/dev-docs/gradle-help/docker.txt b/dev-docs/gradle-help/docker.txt index b691a3359b10..94a431f526c5 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,15 +92,8 @@ 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. +Build and push for a single specific platform: + SOLR_DOCKER_PLATFORM=linux/arm64 ./gradlew dockerPush Testing ------- diff --git a/solr/docker/README.md b/solr/docker/README.md index 109fd18f979a..747bc6b23a62 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 e5f07c6aac91..79e165d08a4f 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) From 7c14c9e9f456060a81073d0f684fb3f4f83b7259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Mon, 22 Dec 2025 21:30:57 +0100 Subject: [PATCH 2/2] No need for example on single platform --- dev-docs/gradle-help/docker.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/dev-docs/gradle-help/docker.txt b/dev-docs/gradle-help/docker.txt index 94a431f526c5..fa632a66505f 100644 --- a/dev-docs/gradle-help/docker.txt +++ b/dev-docs/gradle-help/docker.txt @@ -92,9 +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. -Build and push for a single specific platform: - SOLR_DOCKER_PLATFORM=linux/arm64 ./gradlew dockerPush - Testing -------