@@ -132,7 +132,7 @@ dependencies {
132132 fips " org.bouncycastle:bctls-fips:1.0.19"
133133}
134134
135- ext. expansions = { Architecture architecture , DockerBase base ->
135+ ext. expansions = { Architecture architecture , DockerBase base , String publicationContext = ' ' ->
136136 def (major, minor) = VersionProperties . elasticsearch. split(" \\ ." )
137137
138138 // We tag our Docker images with various pieces of information, including a timestamp
@@ -152,6 +152,7 @@ ext.expansions = { Architecture architecture, DockerBase base ->
152152 ' license' : base == DockerBase . IRON_BANK ? ' Elastic License 2.0' : ' Elastic-License-2.0' ,
153153 ' package_manager' : base. packageManager,
154154 ' docker_base' : base. name(). toLowerCase(),
155+ ' docker_context' : publicationContext,
155156 ' version' : VersionProperties . elasticsearch,
156157 ' major_minor_version' : " ${ major} .${ minor} " ,
157158 ' retry' : ShellRetry
@@ -179,9 +180,9 @@ private static String taskName(String prefix, Architecture architecture, DockerB
179180 suffix
180181}
181182
182- ext. dockerBuildContext = { Architecture architecture , DockerBase base ->
183+ ext. dockerBuildContext = { Architecture architecture , DockerBase base , String publicationContext = ' ' ->
183184 copySpec {
184- final Map<String , String > varExpansions = expansions(architecture, base)
185+ final Map<String , String > varExpansions = expansions(architecture, base, publicationContext )
185186 final Path projectDir = project. projectDir. toPath()
186187
187188 if (base == DockerBase . IRON_BANK ) {
@@ -291,17 +292,22 @@ tasks.named("composeUp").configure {
291292 dependsOn tasks. named(" preProcessFixture" )
292293}
293294
294- void addBuildDockerContextTask (Architecture architecture , DockerBase base ) {
295+
296+ def exportDockerImages = tasks. register(" exportDockerImages" )
297+ def exportCompressedDockerImages = tasks. register(" exportCompressedDockerImages" )
298+ def exportDockerContexts = tasks. register(" exportDockerContexts" )
299+
300+ void addBuildDockerContextTask (Architecture architecture , DockerBase base , String taskSuffix = ' DockerContext' , String classifier = " docker-build-context" ) {
295301 String configDirectory = base == DockerBase . IRON_BANK ? ' scripts' : ' config'
296302 String arch = architecture == Architecture . AARCH64 ? ' -aarch64' : ' '
297303
298304 final TaskProvider<Tar > buildDockerContextTask =
299- tasks. register(taskName(' build' , architecture, base, ' DockerContext ' ), Tar ) {
305+ tasks. register(taskName(' build' , architecture, base, taskSuffix ), Tar ) {
300306 archiveExtension = ' tar.gz'
301307 compression = Compression . GZIP
302- archiveClassifier = " docker-build-context ${ arch} "
308+ archiveClassifier = " ${ classifier } ${ arch} "
303309 archiveBaseName = " elasticsearch${ base.suffix} "
304- with dockerBuildContext(architecture, base)
310+ with dockerBuildContext(architecture, base, classifier )
305311
306312 into(configDirectory) {
307313 from(configurations. log4jConfig) {
@@ -344,6 +350,10 @@ void addBuildDockerContextTask(Architecture architecture, DockerBase base) {
344350 onlyIf(" $architecture supported" ) { serviceProvider. get(). isArchitectureSupported(architecture) }
345351 }
346352
353+ exportDockerContexts. configure {
354+ dependsOn buildDockerContextTask
355+ }
356+
347357 if (base == DockerBase . IRON_BANK ) {
348358 tasks. named(" assemble" ). configure {
349359 dependsOn(buildDockerContextTask)
@@ -578,12 +588,14 @@ for (final Architecture architecture : Architecture.values()) {
578588 addTransformDockerContextTask(architecture, base)
579589 addBuildDockerImageTask(architecture, base)
580590 }
591+ if (base == DockerBase . DEFAULT ) {
592+ // Add additional docker hub specific context which we use solely for publishing to docker hub.
593+ // At the moment it only differs in not labels added that we need for openshit certification
594+ addBuildDockerContextTask(architecture, base, ' DockerHubContext' , " docker-hub-build-context" )
595+ }
581596 }
582597}
583598
584- def exportDockerImages = tasks. register(" exportDockerImages" )
585- def exportCompressedDockerImages = tasks. register(" exportCompressedDockerImages" )
586-
587599/*
588600 * The export subprojects write out the generated Docker images to disk, so
589601 * that they can be easily reloaded, for example into a VM for distribution testing
0 commit comments