From d04426e23a9914d0e3bedd6d184f99b9bc606c37 Mon Sep 17 00:00:00 2001 From: jrmccluskey Date: Tue, 21 Jul 2026 15:34:17 +0000 Subject: [PATCH 1/2] [Experimental] Use zstd compression in Docker builds --- ...it_Python_ValidatesContainer_Dataflow.json | 2 +- .../beam_PreCommit_Flink_Container.json | 2 +- .../beam/gradle/BeamDockerPlugin.groovy | 24 +++++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/trigger_files/beam_PostCommit_Python_ValidatesContainer_Dataflow.json b/.github/trigger_files/beam_PostCommit_Python_ValidatesContainer_Dataflow.json index 60eb7272a936..327fe1987c50 100644 --- a/.github/trigger_files/beam_PostCommit_Python_ValidatesContainer_Dataflow.json +++ b/.github/trigger_files/beam_PostCommit_Python_ValidatesContainer_Dataflow.json @@ -1,4 +1,4 @@ { "comment": "Modify this file in a trivial way to cause this test suite to run", - "modification": 4 + "modification": 5 } \ No newline at end of file diff --git a/.github/trigger_files/beam_PreCommit_Flink_Container.json b/.github/trigger_files/beam_PreCommit_Flink_Container.json index bbdc3a3910ef..62ae7886c573 100644 --- a/.github/trigger_files/beam_PreCommit_Flink_Container.json +++ b/.github/trigger_files/beam_PreCommit_Flink_Container.json @@ -1,4 +1,4 @@ { "comment": "Modify this file in a trivial way to cause this test suite to run", - "modification": 3 + "modification": 4 } diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy index 6963f96d7313..f807afdf9e2a 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy @@ -61,6 +61,7 @@ class BeamDockerPlugin implements Plugin { boolean push = false String builder = null String target = null + String compression = 'zstd' File resolvedDockerfile = null File resolvedDockerComposeTemplate = null @@ -72,6 +73,9 @@ class BeamDockerPlugin implements Plugin { DockerExtension(Project project) { this.project = project this.copySpec = project.copySpec() + if (project.hasProperty('docker-compression')) { + this.compression = project.property('docker-compression') + } } void resolvePathsAndValidate() { @@ -235,13 +239,23 @@ class BeamDockerPlugin implements Plugin { if (!ext.platform.isEmpty()) { buildCommandLine.addAll('--platform', String.join(',', ext.platform)) } - if (ext.load) { - buildCommandLine.add '--load' + if (ext.load && ext.push) { + throw new Exception("cannot combine 'push' and 'load' options") } - if (ext.push) { - buildCommandLine.add '--push' + if (ext.compression != null && !ext.compression.isEmpty()) { + if (ext.push) { + buildCommandLine.add "--output=type=registry,compression=${ext.compression},force-compression=true,oci-mediatypes=true" + } else if (ext.load) { + buildCommandLine.add "--output=type=docker,compression=${ext.compression},force-compression=true" + } else { + buildCommandLine.add "--output=type=image,compression=${ext.compression},force-compression=true,oci-mediatypes=true" + } + } else { if (ext.load) { - throw new Exception("cannot combine 'push' and 'load' options") + buildCommandLine.add '--load' + } + if (ext.push) { + buildCommandLine.add '--push' } } if (ext.builder != null) { From 8b78b02adf5ef87a7fe4731412b2d4b47e1fe9d8 Mon Sep 17 00:00:00 2001 From: jrmccluskey Date: Tue, 21 Jul 2026 17:54:08 +0000 Subject: [PATCH 2/2] fix load errors --- .../main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy index f807afdf9e2a..574e34118905 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamDockerPlugin.groovy @@ -246,7 +246,7 @@ class BeamDockerPlugin implements Plugin { if (ext.push) { buildCommandLine.add "--output=type=registry,compression=${ext.compression},force-compression=true,oci-mediatypes=true" } else if (ext.load) { - buildCommandLine.add "--output=type=docker,compression=${ext.compression},force-compression=true" + buildCommandLine.add '--load' } else { buildCommandLine.add "--output=type=image,compression=${ext.compression},force-compression=true,oci-mediatypes=true" }