33#
44# Beginning of multi stage Dockerfile
55# ###############################################################################
6+
67<% /*
78 This file is passed through Groovy's SimpleTemplateEngine, so dollars and backslashes
89 have to be escaped in order for them to appear in the final Dockerfile. You
1314 We use control-flow tags in this file to conditionally render the content. The
1415 layout/presentation here has been adjusted so that it looks reasonable when rendered,
1516 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.
1620*/ %>
21+
1722<% if (docker_base == "ubi") { %>
1823################################################################################
1924# Build stage 0 `builder`:
2025# Extract Elasticsearch artifact
2126################################################################################
22-
2327FROM ${base_image} AS builder
2428
2529# Install required packages to extract the Elasticsearch distribution
@@ -44,7 +48,21 @@ RUN set -eux ; \\
4448 rm \$ {tini_bin}.sha256sum ; \\
4549 mv \$ {tini_bin} /bin/tini ; \\
4650 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+
4762<% } else { %>
63+
64+ <% /* CentOS builds are actaully a custom base image with a minimal set of dependencies */ %>
65+
4866################################################################################
4967# Stage 1. Build curl statically. Installing it from RPM on CentOS pulls in too
5068# many dependencies.
@@ -194,6 +212,7 @@ COPY --from=curl /work/curl /rootfs/usr/bin/curl
194212# Step 3. Fetch the Elasticsearch distribution and configure it for Docker
195213# ###############################################################################
196214FROM ${base_image} AS builder
215+
197216<% } %>
198217
199218RUN mkdir /usr/share/elasticsearch
@@ -202,16 +221,17 @@ WORKDIR /usr/share/elasticsearch
202221# Fetch the appropriate Elasticsearch distribution for this architecture
203222${source_elasticsearch}
204223
205- RUN tar zxf /opt/elasticsearch.tar.gz --strip-components=1
224+ RUN tar - zxf /opt/elasticsearch.tar.gz --strip-components=1
206225
207226# Configure the distribution for Docker
208227RUN 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
210229RUN 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/
212231RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
213232
214- <% if (docker_base == "ubi" ) { %>
233+ <% if (docker_base == "ubi" || docker_base == "iron_bank" ) { %>
234+
215235# ###############################################################################
216236# Build stage 1 (the actual Elasticsearch image):
217237#
@@ -221,6 +241,8 @@ RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
221241
222242FROM ${base_image}
223243
244+ <% if (docker_base == "ubi" ) { %>
245+
224246RUN for iter in {1..10}; do \\
225247 ${package_manager} update --setopt=tsflags=nodocs -y && \\
226248 ${package_manager} install --setopt=tsflags=nodocs -y \\
@@ -231,11 +253,26 @@ RUN for iter in {1..10}; do \\
231253 done; \\
232254 (exit \$ exit_code)
233255
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+
234269RUN groupadd -g 1000 elasticsearch && \\
235270 adduser -u 1000 -g 1000 -G 0 -d /usr/share/elasticsearch elasticsearch && \\
236271 chmod 0775 /usr/share/elasticsearch && \\
237272 chown -R 1000:0 /usr/share/elasticsearch
273+
238274<% } else { %>
275+
239276################################################################################
240277# Stage 4. Build the final image, using the rootfs above as the basis, and
241278# copying in the Elasticsearch distribution
@@ -250,13 +287,15 @@ RUN addgroup -g 1000 elasticsearch && \\
250287 addgroup elasticsearch root && \\
251288 chmod 0775 /usr/share/elasticsearch && \\
252289 chgrp 0 /usr/share/elasticsearch
290+
253291<% } %>
254292
255293ENV ELASTIC_CONTAINER true
256294
257295WORKDIR /usr/share/elasticsearch
258296COPY --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") { %>
260299COPY --from=builder --chown=0:0 /bin/tini /bin/tini
261300<% } %>
262301
@@ -267,7 +306,7 @@ RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /usr/share/elasticsearch/jdk
267306
268307ENV PATH /usr/share/elasticsearch/bin:\$ PATH
269308
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
271310
272311# 1. The JDK's directories' permissions don't allow `java` to be executed under a different
273312# group to the default. Fix this.
@@ -303,7 +342,8 @@ LABEL org.label-schema.build-date="${build_date}" \\
303342 org.opencontainers.image.url="https://www.elastic.co/products/elasticsearch" \\
304343 org.opencontainers.image.vendor="Elastic" \\
305344 org.opencontainers.image.version="${version}"
306- <% if (docker_base == 'ubi' ) { %>
345+
346+ <% if (docker_base == 'ubi' || docker_base == 'iron_bank' ) { %>
307347LABEL name="Elasticsearch" \\
308348309349 vendor="Elastic" \\
@@ -324,6 +364,10 @@ ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
324364# Dummy overridable parameter parsed by entrypoint
325365CMD ["eswrapper" ]
326366
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+
327371# ###############################################################################
328372# End of multi-stage Dockerfile
329373# ###############################################################################
0 commit comments