@@ -21,29 +21,31 @@ dependencies {
21
21
restSpec project(' :rest-api-spec' )
22
22
}
23
23
24
- ext. expansions = { oss , local ->
24
+ ext. expansions = { oss , ubi , local ->
25
25
final String classifier = ' linux-x86_64'
26
26
final String elasticsearch = oss ? " elasticsearch-oss-${ VersionProperties.elasticsearch} -${ classifier} .tar.gz" : " elasticsearch-${ VersionProperties.elasticsearch} -${ classifier} .tar.gz"
27
27
return [
28
+ ' base_image' : ubi ? ' registry.access.redhat.com/ubi7/ubi-minimal:7.7' : ' centos:7' ,
28
29
' build_date' : project. ext. buildDate,
29
30
' elasticsearch' : elasticsearch,
30
31
' git_revision' : project. ext. gitRevision,
31
32
' license' : oss ? ' Apache-2.0' : ' Elastic-License' ,
33
+ ' package_manager' : ubi ? ' microdnf' : ' yum' ,
32
34
' source_elasticsearch' : local ? " COPY $elasticsearch /opt/" : " RUN cd /opt && curl --retry 8 -s -L -O https://artifacts.elastic.co/downloads/elasticsearch/${ elasticsearch} && cd -" ,
33
35
' version' : VersionProperties . elasticsearch
34
36
]
35
37
}
36
38
37
- private static String files (final boolean oss ) {
38
- return " build/${ oss ? 'oss-' : ''} docker"
39
+ private static String buildPath (final boolean oss , final boolean ubi ) {
40
+ return " build/${ oss ? 'oss-' : ''}${ ubi ? 'ubi-' : '' } docker"
39
41
}
40
42
41
- private static String taskName (final String prefix , final boolean oss , final String suffix ) {
42
- return " ${ prefix}${ oss ? 'Oss' : ''}${ suffix} "
43
+ private static String taskName (final String prefix , final boolean oss , final boolean ubi , final String suffix ) {
44
+ return " ${ prefix}${ oss ? 'Oss' : ''}${ ubi ? 'Ubi': '' }${ suffix} "
43
45
}
44
46
45
47
project. ext {
46
- dockerBuildContext = { boolean oss , boolean local ->
48
+ dockerBuildContext = { boolean oss , boolean ubi , boolean local ->
47
49
copySpec {
48
50
into(' bin' ) {
49
51
from project. projectDir. toPath(). resolve(" src/docker/bin" )
@@ -55,24 +57,26 @@ project.ext {
55
57
* by creating config files in oss or default build-context sub-modules.
56
58
*/
57
59
from project. projectDir. toPath(). resolve(" src/docker/config" )
58
- from project. projectDir. toPath(). resolve(oss ? " oss-docker-build-context" : " docker-build-context" ). resolve(" src/docker/config" )
60
+ if (oss) {
61
+ from project. projectDir. toPath(). resolve(" src/docker/config/oss" )
62
+ }
59
63
}
60
64
61
65
from(project. projectDir. toPath(). resolve(" src/docker/Dockerfile" )) {
62
- expand(expansions(oss, local))
66
+ expand(expansions(oss, ubi, local))
63
67
}
64
68
}
65
69
}
66
70
}
67
71
68
- void addCopyDockerContextTask (final boolean oss ) {
69
- task(taskName(" copy" , oss, " DockerContext" ), type : Sync ) {
70
- expansions(oss, true ). each { k , v ->
72
+ void addCopyDockerContextTask (final boolean oss , final boolean ubi ) {
73
+ task(taskName(" copy" , oss, ubi, " DockerContext" ), type : Sync ) {
74
+ expansions(oss, ubi, true ). each { k , v ->
71
75
inputs. property(k, { v. toString() })
72
76
}
73
- into files (oss)
77
+ into buildPath (oss, ubi )
74
78
75
- with dockerBuildContext(oss, true )
79
+ with dockerBuildContext(oss, ubi, true )
76
80
77
81
if (oss) {
78
82
from configurations. ossDockerSource
@@ -144,42 +148,42 @@ task integTest(type: Test) {
144
148
145
149
check. dependsOn integTest
146
150
147
- void addBuildDockerImage (final boolean oss ) {
148
- final Task buildDockerImageTask = task(taskName(" build" , oss, " DockerImage" ), type : LoggedExec ) {
149
- dependsOn taskName(" copy" , oss, " DockerContext" )
151
+ void addBuildDockerImage (final boolean oss , final boolean ubi ) {
152
+ final Task buildDockerImageTask = task(taskName(" build" , oss, ubi, " DockerImage" ), type : LoggedExec ) {
153
+ dependsOn taskName(" copy" , oss, ubi, " DockerContext" )
150
154
List<String > tags
151
155
if (oss) {
152
156
tags = [
153
- " docker.elastic.co/elasticsearch/elasticsearch-oss:${ VersionProperties.elasticsearch} " ,
154
- " elasticsearch-oss:test"
157
+ " docker.elastic.co/elasticsearch/elasticsearch-oss:${ VersionProperties.elasticsearch}${ ubi ? '-ubi7' : '' } " ,
158
+ " elasticsearch-oss:test${ ubi ? '-ubi7' : '' } "
155
159
]
156
160
} else {
157
161
tags = [
158
- " elasticsearch:${ VersionProperties.elasticsearch} " ,
159
- " docker.elastic.co/elasticsearch/elasticsearch:${ VersionProperties.elasticsearch} " ,
160
- " docker.elastic.co/elasticsearch/elasticsearch-full:${ VersionProperties.elasticsearch} " ,
161
- " elasticsearch:test" ,
162
+ " elasticsearch:${ VersionProperties.elasticsearch}${ ubi ? '-ubi7' : '' } " ,
163
+ " docker.elastic.co/elasticsearch/elasticsearch:${ VersionProperties.elasticsearch}${ ubi ? '-ubi7' : '' } " ,
164
+ " docker.elastic.co/elasticsearch/elasticsearch-full:${ VersionProperties.elasticsearch}${ ubi ? '-ubi7' : '' } " ,
165
+ " elasticsearch:test${ ubi ? '-ubi7' : '' } " ,
162
166
]
163
167
}
164
168
executable ' docker'
165
- final List<String > dockerArgs = [' build' , files (oss), ' --pull' , ' --no-cache' ]
169
+ final List<String > dockerArgs = [' build' , buildPath (oss, ubi ), ' --pull' , ' --no-cache' ]
166
170
for (final String tag : tags) {
167
171
dockerArgs. add(' --tag' )
168
172
dockerArgs. add(tag)
169
173
}
170
174
args dockerArgs. toArray()
171
175
}
176
+ assemble. dependsOn(buildDockerImageTask)
172
177
BuildPlugin . requireDocker(buildDockerImageTask)
173
178
}
174
179
175
180
for (final boolean oss : [false , true ]) {
176
- addCopyDockerContextTask(oss)
177
- addBuildDockerImage(oss)
181
+ for (final boolean ubi : [false , true ]) {
182
+ addCopyDockerContextTask(oss, ubi)
183
+ addBuildDockerImage(oss, ubi)
184
+ }
178
185
}
179
186
180
- assemble. dependsOn " buildOssDockerImage"
181
- assemble. dependsOn " buildDockerImage"
182
-
183
187
// We build the images used in compose locally, but the pull command insists on using a repository
184
188
// thus we must disable it to prevent it from doing so.
185
189
// Everything will still be pulled since we will build the local images on a pull
@@ -195,25 +199,26 @@ subprojects { Project subProject ->
195
199
if (subProject. name. contains(' docker-export' )) {
196
200
apply plugin : ' distribution'
197
201
198
- final boolean oss = subProject. name. startsWith(' oss' )
202
+ final boolean oss = subProject. name. contains(' oss-' )
203
+ final boolean ubi = subProject. name. contains(' ubi-' )
199
204
200
- def exportTaskName = taskName(" export" , oss, " DockerImage" )
201
- def buildTaskName = taskName(" build" , oss, " DockerImage" )
202
- def tarFile = " ${ parent.projectDir} /build/elasticsearch${ oss ? '-oss' : ''} _test.${ VersionProperties.elasticsearch} .docker.tar"
205
+ def exportTaskName = taskName(" export" , oss, ubi, " DockerImage" )
206
+ def buildTaskName = taskName(" build" , oss, ubi, " DockerImage" )
207
+ def tarFile = " ${ parent.projectDir} /build/elasticsearch${ oss ? '-oss' : ''} _test.${ VersionProperties.elasticsearch}${ ubi ? '-ubi7' : '' } .docker.tar"
203
208
204
209
final Task exportDockerImageTask = task(exportTaskName, type : LoggedExec ) {
205
210
executable ' docker'
206
211
args " save" ,
207
212
" -o" ,
208
213
tarFile,
209
- " elasticsearch${ oss ? '-oss' : ''} :test"
214
+ " elasticsearch${ oss ? '-oss' : ''}${ ubi ? '-ubi7' : '' } :test"
210
215
}
211
216
212
217
exportDockerImageTask. dependsOn(parent. tasks. getByName(buildTaskName))
213
218
214
219
artifacts. add(' default' , file(tarFile)) {
215
220
type ' tar'
216
- name " elasticsearch${ oss ? '-oss' : ''} "
221
+ name " elasticsearch${ oss ? '-oss' : ''}${ ubi ? '-ubi7' : '' } "
217
222
builtBy exportTaskName
218
223
}
219
224
0 commit comments