@@ -117,7 +117,7 @@ dependencies {
117117  fips " org.bouncycastle:bctls-fips:1.0.19" 
118118}
119119
120- ext. expansions =  { Architecture  architecture , DockerBase  base  -> 
120+ ext. expansions =  { Architecture  architecture , DockerBase  base ,  String   publicationContext   =   ' '   -> 
121121  def  (major, minor) =  VersionProperties . elasticsearch. split(" \\ ."  )
122122
123123  //  We tag our Docker images with various pieces of information, including a timestamp
@@ -137,6 +137,7 @@ ext.expansions = { Architecture architecture, DockerBase base ->
137137    ' license'              : base ==  DockerBase . IRON_BANK  ?  ' Elastic License 2.0'   :  ' Elastic-License-2.0'  ,
138138    ' package_manager'      : base. packageManager,
139139    ' docker_base'          : base. name(). toLowerCase(),
140+     ' docker_context'       : publicationContext,
140141    ' version'              : VersionProperties . elasticsearch,
141142    ' major_minor_version'  : " ${ major}  .${ minor} "  ,
142143    ' retry'                : ShellRetry 
@@ -164,9 +165,9 @@ private static String taskName(String prefix, Architecture architecture, DockerB
164165    suffix
165166}
166167
167- ext. dockerBuildContext =  { Architecture  architecture , DockerBase  base  -> 
168+ ext. dockerBuildContext =  { Architecture  architecture , DockerBase  base ,  String   publicationContext   =   ' '   -> 
168169  copySpec {
169-     final  Map<String , String >  varExpansions =  expansions(architecture, base)
170+     final  Map<String , String >  varExpansions =  expansions(architecture, base, publicationContext )
170171    final  Path  projectDir =  project. projectDir. toPath()
171172
172173    if  (base ==  DockerBase . IRON_BANK ) {
@@ -276,17 +277,22 @@ tasks.named("composeUp").configure {
276277  dependsOn tasks. named(" preProcessFixture"  )
277278}
278279
279- void  addBuildDockerContextTask (Architecture  architecture , DockerBase  base ) {
280+ 
281+ def  exportDockerImages =  tasks. register(" exportDockerImages"  )
282+ def  exportCompressedDockerImages =  tasks. register(" exportCompressedDockerImages"  )
283+ def  exportDockerContexts =  tasks. register(" exportDockerContexts"  )
284+ 
285+ void  addBuildDockerContextTask (Architecture  architecture , DockerBase  base , String  taskSuffix  =  ' DockerContext'  , String  classifier  =  " docker-build-context"  ) {
280286  String  configDirectory =  base ==  DockerBase . IRON_BANK  ?  ' scripts'   :  ' config' 
281287  String  arch =  architecture ==  Architecture . AARCH64  ?  ' -aarch64'   :  ' ' 
282288
283289  final  TaskProvider<Tar >  buildDockerContextTask = 
284-     tasks. register(taskName(' build'  , architecture, base, ' DockerContext '  ), Tar ) {
290+     tasks. register(taskName(' build'  , architecture, base, taskSuffix ), Tar ) {
285291      archiveExtension =  ' tar.gz' 
286292      compression =  Compression . GZIP 
287-       archiveClassifier =  " docker-build-context ${ arch} " 
293+       archiveClassifier =  " ${ classifier } ${ arch} " 
288294      archiveBaseName =  " elasticsearch${ base.suffix} " 
289-       with dockerBuildContext(architecture, base)
295+       with dockerBuildContext(architecture, base, classifier )
290296
291297      into(configDirectory) {
292298        from(configurations. log4jConfig) {
@@ -329,6 +335,10 @@ void addBuildDockerContextTask(Architecture architecture, DockerBase base) {
329335      onlyIf(" $architecture   supported"  ) { serviceProvider. get(). isArchitectureSupported(architecture) }
330336    }
331337
338+   exportDockerContexts. configure {
339+     dependsOn buildDockerContextTask
340+   }
341+ 
332342  if  (base ==  DockerBase . IRON_BANK ) {
333343    tasks. named(" assemble"  ). configure {
334344      dependsOn(buildDockerContextTask)
@@ -563,12 +573,14 @@ for (final Architecture architecture : Architecture.values()) {
563573      addTransformDockerContextTask(architecture, base)
564574      addBuildDockerImageTask(architecture, base)
565575    }
576+     if (base ==  DockerBase . DEFAULT ) {
577+       //  Add additional docker hub specific context which we use solely for publishing to docker hub.
578+       //  At the moment it only differs in not labels added that we need for openshift certification
579+       addBuildDockerContextTask(architecture, base, ' DockerHubContext'  , " docker-hub-build-context"  )
580+     }
566581  }
567582}
568583
569- def  exportDockerImages =  tasks. register(" exportDockerImages"  )
570- def  exportCompressedDockerImages =  tasks. register(" exportCompressedDockerImages"  )
571- 
572584/* 
573585 * The export subprojects write out the generated Docker images to disk, so 
574586 * that they can be easily reloaded, for example into a VM for distribution testing 
0 commit comments