@@ -19,17 +19,38 @@ dependencies {
19
19
}
20
20
21
21
ext. expansions = { oss ->
22
+ final String elasticsearch = oss ? " elasticsearch-oss-${ VersionProperties.elasticsearch} .tar.gz" : " elasticsearch-${ VersionProperties.elasticsearch} .tar.gz"
23
+ final String ingestGeoip = " ingest-geoip-${ VersionProperties.elasticsearch} .zip"
24
+ final String ingestUserAgent = " ingest-user-agent-${ VersionProperties.elasticsearch} .zip"
22
25
return [
23
- ' elasticsearch' : oss ? " elasticsearch-oss-${ VersionProperties.elasticsearch} .tar.gz" : " elasticsearch-${ VersionProperties.elasticsearch} .tar.gz" ,
24
- ' jdkUrl' : ' https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz' ,
25
- ' jdkVersion' : ' 11.0.1' ,
26
- ' license' : oss ? ' Apache-2.0' : ' Elastic License' ,
27
- ' ingest-geoip' : " ingest-geoip-${ VersionProperties.elasticsearch} .zip" ,
28
- ' ingest-user-agent' : " ingest-user-agent-${ VersionProperties.elasticsearch} .zip" ,
29
- ' version' : VersionProperties . elasticsearch
26
+ ' elasticsearch' : elasticsearch,
27
+ ' jdkUrl' : ' https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz' ,
28
+ ' jdkVersion' : ' 11.0.1' ,
29
+ ' license' : oss ? ' Apache-2.0' : ' Elastic License' ,
30
+ ' source_elasticsearch' : local() ? " COPY $elasticsearch $ingestGeoip $ingestUserAgent /opt/" : " RUN cd /opt && curl --retry 8 -s -L -O https://artifacts.elastic.co/downloads/elasticsearch/${ elasticsearch} && cd -" ,
31
+ ' ingest-geoip-plugin' : local() ? " file:///opt/$ingestGeoip " : " ingest-geoip" ,
32
+ ' ingest-user-agent-plugin' : local() ? " file:///opt/$ingestUserAgent " : " ingest-user-agent" ,
33
+ ' version' : VersionProperties . elasticsearch
30
34
]
31
35
}
32
36
37
+ /*
38
+ * We need to be able to render a Dockerfile that references the official artifacts on https://artifacts.elastic.co. For this, we use a
39
+ * substitution in the Dockerfile template where we can either replace source_elasticsearch with a COPY from the Docker build context, or
40
+ * a RUN curl command to retrieve the artifact from https://artifacts.elastic.co. The system property build.docker.source, which can be
41
+ * either "local" (default) or "remote" controls which version of the Dockerfile is produced.
42
+ */
43
+ private static boolean local () {
44
+ final String buildDockerSource = System . getProperty(" build.docker.source" )
45
+ if (buildDockerSource == null || " local" . equals(buildDockerSource)) {
46
+ return true
47
+ } else if (" remote" . equals(buildDockerSource)) {
48
+ return false
49
+ } else {
50
+ throw new IllegalArgumentException (" expected build.docker.source to be [local] or [remote] but was [" + buildDockerSource + " ]" )
51
+ }
52
+ }
53
+
33
54
private static String files (final boolean oss ) {
34
55
return " build/${ oss ? 'oss-' : ''} docker"
35
56
}
@@ -50,19 +71,21 @@ void addCopyDockerContextTask(final boolean oss) {
50
71
from ' src/docker/config'
51
72
}
52
73
53
- if (oss) {
54
- from configurations. ossDockerSource
55
- } else {
56
- from configurations. dockerSource
57
- }
74
+ if (local()) {
75
+ if (oss) {
76
+ from configurations. ossDockerSource
77
+ } else {
78
+ from configurations. dockerSource
79
+ }
58
80
59
- from configurations. dockerPlugins
81
+ from configurations. dockerPlugins
82
+ }
60
83
}
61
84
}
62
85
63
86
void addCopyDockerfileTask (final boolean oss ) {
64
87
task(taskName(" copy" , oss, " Dockerfile" ), type : Copy ) {
65
- mustRunAfter( taskName(" copy" , oss, " DockerContext" ) )
88
+ dependsOn taskName(" copy" , oss, " DockerContext" )
66
89
into files(oss)
67
90
68
91
from(' src/docker/Dockerfile' ) {
@@ -73,7 +96,6 @@ void addCopyDockerfileTask(final boolean oss) {
73
96
74
97
void addBuildDockerImage (final boolean oss ) {
75
98
final Task buildDockerImageTask = task(taskName(" build" , oss, " DockerImage" ), type : LoggedExec ) {
76
- dependsOn taskName(" copy" , oss, " DockerContext" )
77
99
dependsOn taskName(" copy" , oss, " Dockerfile" )
78
100
List<String > tags
79
101
if (oss) {
0 commit comments