@@ -61,6 +61,7 @@ class BeamDockerPlugin implements Plugin<Project> {
6161 boolean push = false
6262 String builder = null
6363 String target = null
64+ String compression = ' zstd'
6465
6566 File resolvedDockerfile = null
6667 File resolvedDockerComposeTemplate = null
@@ -72,6 +73,9 @@ class BeamDockerPlugin implements Plugin<Project> {
7273 DockerExtension (Project project ) {
7374 this . project = project
7475 this . copySpec = project. copySpec()
76+ if (project. hasProperty(' docker-compression' )) {
77+ this . compression = project. property(' docker-compression' )
78+ }
7579 }
7680
7781 void resolvePathsAndValidate () {
@@ -235,13 +239,23 @@ class BeamDockerPlugin implements Plugin<Project> {
235239 if (! ext. platform. isEmpty()) {
236240 buildCommandLine. addAll(' --platform' , String . join(' ,' , ext. platform))
237241 }
238- if (ext. load) {
239- buildCommandLine . add ' -- load'
242+ if (ext. load && ext . push ) {
243+ throw new Exception ( " cannot combine 'push' and ' load' options " )
240244 }
241- if (ext. push) {
242- buildCommandLine. add ' --push'
245+ if (ext. compression != null && ! ext. compression. isEmpty()) {
246+ if (ext. push) {
247+ buildCommandLine. add " --output=type=registry,compression=${ ext.compression} ,force-compression=true,oci-mediatypes=true"
248+ } else if (ext. load) {
249+ buildCommandLine. add ' --load'
250+ } else {
251+ buildCommandLine. add " --output=type=image,compression=${ ext.compression} ,force-compression=true,oci-mediatypes=true"
252+ }
253+ } else {
243254 if (ext. load) {
244- throw new Exception (" cannot combine 'push' and 'load' options" )
255+ buildCommandLine. add ' --load'
256+ }
257+ if (ext. push) {
258+ buildCommandLine. add ' --push'
245259 }
246260 }
247261 if (ext. builder != null ) {
0 commit comments