3
3
#
4
4
# Beginning of multi stage Dockerfile
5
5
# ###############################################################################
6
+
6
7
<% /*
7
8
This file is passed through Groovy's SimpleTemplateEngine, so dollars and backslashes
8
9
have to be escaped in order for them to appear in the final Dockerfile. You
13
14
We use control-flow tags in this file to conditionally render the content. The
14
15
layout/presentation here has been adjusted so that it looks reasonable when rendered,
15
16
at the slight expense of how it looks here.
17
+
18
+ Note that this file is also filtered to squash together newlines, so we can
19
+ add as many newlines here as necessary to improve legibility.
16
20
*/ %>
21
+
17
22
<% if (docker_base == "ubi") { %>
18
23
################################################################################
19
24
# Build stage 0 `builder`:
20
25
# Extract Elasticsearch artifact
21
26
################################################################################
22
-
23
27
FROM ${base_image} AS builder
24
28
25
29
# Install required packages to extract the Elasticsearch distribution
@@ -44,7 +48,21 @@ RUN set -eux ; \\
44
48
rm \$ {tini_bin}.sha256sum ; \\
45
49
mv \$ {tini_bin} /bin/tini ; \\
46
50
chmod +x /bin/tini
51
+
52
+ <% } else if (docker_base == ' iron_bank') { %>
53
+ ${build_args}
54
+
55
+ FROM ${base_image} AS builder
56
+
57
+ # `tini` is a tiny but valid init for containers. This is used to cleanly
58
+ # control how ES and any child processes are shut down.
59
+ COPY tini /bin/tini
60
+ RUN chmod 0755 /bin/tini
61
+
47
62
<% } else { %>
63
+
64
+ <% /* CentOS builds are actaully a custom base image with a minimal set of dependencies */ %>
65
+
48
66
################################################################################
49
67
# Stage 1. Build curl statically. Installing it from RPM on CentOS pulls in too
50
68
# many dependencies.
@@ -194,6 +212,7 @@ COPY --from=curl /work/curl /rootfs/usr/bin/curl
194
212
# Step 3. Fetch the Elasticsearch distribution and configure it for Docker
195
213
# ###############################################################################
196
214
FROM ${base_image} AS builder
215
+
197
216
<% } %>
198
217
199
218
RUN mkdir /usr/share/elasticsearch
@@ -202,16 +221,17 @@ WORKDIR /usr/share/elasticsearch
202
221
# Fetch the appropriate Elasticsearch distribution for this architecture
203
222
${source_elasticsearch}
204
223
205
- RUN tar zxf /opt/elasticsearch.tar.gz --strip-components=1
224
+ RUN tar - zxf /opt/elasticsearch.tar.gz --strip-components=1
206
225
207
226
# Configure the distribution for Docker
208
227
RUN sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' /usr/share/elasticsearch/bin/elasticsearch-env
209
- RUN mkdir -p config config/jvm.options.d data logs
228
+ RUN mkdir -p config config/jvm.options.d data logs plugins
210
229
RUN chmod 0775 config config/jvm.options.d data logs plugins
211
- COPY config /elasticsearch.yml config /log4j2.properties config/
230
+ COPY ${config_dir} /elasticsearch.yml ${config_dir} /log4j2.properties config/
212
231
RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
213
232
214
- <% if (docker_base == "ubi" ) { %>
233
+ <% if (docker_base == "ubi" || docker_base == "iron_bank" ) { %>
234
+
215
235
# ###############################################################################
216
236
# Build stage 1 (the actual Elasticsearch image):
217
237
#
@@ -221,6 +241,8 @@ RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
221
241
222
242
FROM ${base_image}
223
243
244
+ <% if (docker_base == "ubi" ) { %>
245
+
224
246
RUN for iter in {1..10}; do \\
225
247
${package_manager} update --setopt=tsflags=nodocs -y && \\
226
248
${package_manager} install --setopt=tsflags=nodocs -y \\
@@ -231,11 +253,26 @@ RUN for iter in {1..10}; do \\
231
253
done; \\
232
254
(exit \$ exit_code)
233
255
256
+ %> } else { %>
257
+
258
+ <%
259
+ /* Reviews of the Iron Bank Dockerfile said that they preferred simpler */
260
+ /* scripting so this version doesn't have the retry loop featured above. */
261
+ %>
262
+ RUN ${package_manager} update --setopt=tsflags=nodocs -y && \\
263
+ ${package_manager} install --setopt=tsflags=nodocs -y \\
264
+ nc shadow-utils zip unzip && \\
265
+ ${package_manager} clean all
266
+
267
+ <% } %>
268
+
234
269
RUN groupadd -g 1000 elasticsearch && \\
235
270
adduser -u 1000 -g 1000 -G 0 -d /usr/share/elasticsearch elasticsearch && \\
236
271
chmod 0775 /usr/share/elasticsearch && \\
237
272
chown -R 1000:0 /usr/share/elasticsearch
273
+
238
274
<% } else { %>
275
+
239
276
################################################################################
240
277
# Stage 4. Build the final image, using the rootfs above as the basis, and
241
278
# copying in the Elasticsearch distribution
@@ -250,13 +287,15 @@ RUN addgroup -g 1000 elasticsearch && \\
250
287
addgroup elasticsearch root && \\
251
288
chmod 0775 /usr/share/elasticsearch && \\
252
289
chgrp 0 /usr/share/elasticsearch
290
+
253
291
<% } %>
254
292
255
293
ENV ELASTIC_CONTAINER true
256
294
257
295
WORKDIR /usr/share/elasticsearch
258
296
COPY --from=builder --chown=1000:0 /usr/share/elasticsearch /usr/share/elasticsearch
259
- <% if (docker_base == "ubi" ) { %>
297
+
298
+ <% if (docker_base == "ubi" || docker_base == "iron_bank") { %>
260
299
COPY --from=builder --chown=0:0 /bin/tini /bin/tini
261
300
<% } %>
262
301
@@ -267,7 +306,7 @@ RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /usr/share/elasticsearch/jdk
267
306
268
307
ENV PATH /usr/share/elasticsearch/bin:\$ PATH
269
308
270
- COPY bin /docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
309
+ COPY ${bin_dir} /docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
271
310
272
311
# 1. The JDK's directories' permissions don't allow `java` to be executed under a different
273
312
# group to the default. Fix this.
@@ -303,7 +342,8 @@ LABEL org.label-schema.build-date="${build_date}" \\
303
342
org.opencontainers.image.url="https://www.elastic.co/products/elasticsearch" \\
304
343
org.opencontainers.image.vendor="Elastic" \\
305
344
org.opencontainers.image.version="${version}"
306
- <% if (docker_base == 'ubi' ) { %>
345
+
346
+ <% if (docker_base == 'ubi' || docker_base == 'iron_bank' ) { %>
307
347
LABEL name="Elasticsearch" \\
308
348
309
349
vendor="Elastic" \\
@@ -324,6 +364,10 @@ ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
324
364
# Dummy overridable parameter parsed by entrypoint
325
365
CMD ["eswrapper" ]
326
366
367
+ <% if (docker_base == 'iron_bank' ) { %>
368
+ HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 http://localhost:9200 || exit 1
369
+ <% } %>
370
+
327
371
# ###############################################################################
328
372
# End of multi-stage Dockerfile
329
373
# ###############################################################################
0 commit comments