3
3
#
4
4
# Beginning of multi stage Dockerfile
5
5
# ###############################################################################
6
+ <% /*
7
+ This file is passed through Groovy's SimpleTemplateEngine, so dollars and backslashes
8
+ have to be escaped in order for them to appear in the final Dockerfile. You
9
+ can also comment out blocks, like this one. See:
6
10
11
+ https://docs.groovy-lang.org/latest/html/api/groovy/text/SimpleTemplateEngine.html
12
+ */ %>
7
13
################################################################################
8
14
# Build stage 0 `builder`:
9
15
# Extract elasticsearch artifact
10
- # Install required plugins
11
16
# Set gid=0 and make group perms==owner perms
12
17
################################################################################
13
18
14
- FROM ${base_image} AS builder
15
-
16
- RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && \
17
- yum install --setopt=tsflags=nodocs -y wget gzip shadow-utils tar && \
18
- yum clean all && exit_code=0 && break || exit_code=\$ ? && echo "yum error: retry \$ iter in 10s" && sleep 10; done; \
19
- (exit \$ exit_code)
19
+ FROM centos:7 AS builder
20
20
21
21
# `tini` is a tiny but valid init for containers. This is used to cleanly
22
22
# control how ES and any child processes are shut down.
23
23
#
24
24
# The tini GitHub page gives instructions for verifying the binary using
25
25
# gpg, but the keyservers are slow to return the key and this can fail the
26
- # build. Instead, we check the binary against a checksum that they provide.
27
- RUN wget --no-cookies --quiet https://github.com/krallin/tini/releases/download/v0.19.0/tini-${tini_arch} \
28
- && wget --no-cookies --quiet https://github.com/krallin/tini/releases/download/v0.19.0/tini-${tini_arch}.sha256sum \
29
- && sha256sum -c tini-${tini_arch}.sha256sum \
30
- && mv tini-${tini_arch} /tini \
31
- && chmod +x /tini
26
+ # build. Instead, we check the binary against the published checksum.
27
+ RUN set -eux ; \\
28
+ \\
29
+ tini_bin="" ; \\
30
+ case "\$ (arch)" in \\
31
+ aarch64) tini_bin=' tini-arm64' ;; \\
32
+ x86_64) tini_bin=' tini-amd64' ;; \\
33
+ *) echo >&2 ; echo >&2 "Unsupported architecture \$ (arch)" ; echo >&2 ; exit 1 ;; \\
34
+ esac ; \\
35
+ curl --retry 8 -S -L -O https://github.com/krallin/tini/releases/download/v0.19.0/\$ {tini_bin} ; \\
36
+ curl --retry 8 -S -L -O https://github.com/krallin/tini/releases/download/v0.19.0/\$ {tini_bin}.sha256sum ; \\
37
+ sha256sum -c \$ {tini_bin}.sha256sum ; \\
38
+ rm \$ {tini_bin}.sha256sum ; \\
39
+ mv \$ {tini_bin} /tini ; \\
40
+ chmod +x /tini
32
41
33
42
ENV PATH /usr/share/elasticsearch/bin:\$ PATH
34
43
35
- RUN groupadd -g 1000 elasticsearch && \
44
+ RUN groupadd -g 1000 elasticsearch && \\
36
45
adduser -u 1000 -g 1000 -d /usr/share/elasticsearch elasticsearch
37
46
38
47
WORKDIR /usr/share/elasticsearch
39
48
40
49
${source_elasticsearch}
41
50
42
- RUN tar zxf /opt/${elasticsearch} --strip-components=1
43
- RUN grep ES_DISTRIBUTION_TYPE=tar /usr/share/elasticsearch/bin/elasticsearch-env \
44
- && sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' /usr/share/elasticsearch/bin/elasticsearch-env
51
+ RUN tar zxf /opt/elasticsearch.tar.gz --strip-components=1
52
+ RUN sed -i -e ' s/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' /usr/share/elasticsearch/bin/elasticsearch-env
45
53
RUN mkdir -p config config/jvm.options.d data logs
46
54
RUN chmod 0775 config config/jvm.options.d data logs
47
55
COPY config/elasticsearch.yml config/log4j2.properties config/
@@ -53,20 +61,20 @@ RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
53
61
# Add entrypoint
54
62
################################################################################
55
63
56
- FROM ${base_image}
64
+ FROM centos:7
57
65
58
66
ENV ELASTIC_CONTAINER true
59
67
60
68
COPY --from=builder /tini /tini
61
69
62
- RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && \
63
- yum install --setopt=tsflags=nodocs -y nc shadow-utils zip unzip && \
64
- yum clean all && exit_code=0 && break || exit_code=\$ ? && echo "yum error: retry \$ iter in 10s" && sleep 10; done; \
70
+ RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && \\
71
+ yum install --setopt=tsflags=nodocs -y nc shadow-utils zip unzip && \\
72
+ yum clean all && exit_code=0 && break || exit_code=\$ ? && echo "yum error: retry \$ iter in 10s" && sleep 10; done; \\
65
73
(exit \$ exit_code)
66
74
67
- RUN groupadd -g 1000 elasticsearch && \
68
- adduser -u 1000 -g 1000 -G 0 -d /usr/share/elasticsearch elasticsearch && \
69
- chmod 0775 /usr/share/elasticsearch && \
75
+ RUN groupadd -g 1000 elasticsearch && \\
76
+ adduser -u 1000 -g 1000 -G 0 -d /usr/share/elasticsearch elasticsearch && \\
77
+ chmod 0775 /usr/share/elasticsearch && \\
70
78
chgrp 0 /usr/share/elasticsearch
71
79
72
80
WORKDIR /usr/share/elasticsearch
@@ -81,32 +89,32 @@ ENV PATH /usr/share/elasticsearch/bin:\$PATH
81
89
82
90
COPY bin/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
83
91
84
- RUN chmod g=u /etc/passwd && \
92
+ RUN chmod g=u /etc/passwd && \\
85
93
chmod 0775 /usr/local/bin/docker-entrypoint.sh
86
94
87
95
# Ensure that there are no files with setuid or setgid, in order to mitigate "stackclash" attacks.
88
96
RUN find / -xdev -perm -4000 -exec chmod ug-s {} +
89
97
90
98
EXPOSE 9200 9300
91
99
92
- LABEL org.label-schema.build-date="${build_date}" \
93
- org.label-schema.license="${license}" \
94
- org.label-schema.name="Elasticsearch" \
95
- org.label-schema.schema-version="1.0" \
96
- org.label-schema.url="https://www.elastic.co/products/elasticsearch" \
97
- org.label-schema.usage="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \
98
- org.label-schema.vcs-ref="${git_revision}" \
99
- org.label-schema.vcs-url="https://github.com/elastic/elasticsearch" \
100
- org.label-schema.vendor="Elastic" \
101
- org.label-schema.version="${version}" \
102
- org.opencontainers.image.created="${build_date}" \
103
- org.opencontainers.image.documentation="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \
104
- org.opencontainers.image.licenses="${license}" \
105
- org.opencontainers.image.revision="${git_revision}" \
106
- org.opencontainers.image.source="https://github.com/elastic/elasticsearch" \
107
- org.opencontainers.image.title="Elasticsearch" \
108
- org.opencontainers.image.url="https://www.elastic.co/products/elasticsearch" \
109
- org.opencontainers.image.vendor="Elastic" \
100
+ LABEL org.label-schema.build-date="${build_date}" \\
101
+ org.label-schema.license="${license}" \\
102
+ org.label-schema.name="Elasticsearch" \\
103
+ org.label-schema.schema-version="1.0" \\
104
+ org.label-schema.url="https://www.elastic.co/products/elasticsearch" \\
105
+ org.label-schema.usage="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \\
106
+ org.label-schema.vcs-ref="${git_revision}" \\
107
+ org.label-schema.vcs-url="https://github.com/elastic/elasticsearch" \\
108
+ org.label-schema.vendor="Elastic" \\
109
+ org.label-schema.version="${version}" \\
110
+ org.opencontainers.image.created="${build_date}" \\
111
+ org.opencontainers.image.documentation="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \\
112
+ org.opencontainers.image.licenses="${license}" \\
113
+ org.opencontainers.image.revision="${git_revision}" \\
114
+ org.opencontainers.image.source="https://github.com/elastic/elasticsearch" \\
115
+ org.opencontainers.image.title="Elasticsearch" \\
116
+ org.opencontainers.image.url="https://www.elastic.co/products/elasticsearch" \\
117
+ org.opencontainers.image.vendor="Elastic" \\
110
118
org.opencontainers.image.version="${version}"
111
119
112
120
ENTRYPOINT ["/tini" , "--" , "/usr/local/bin/docker-entrypoint.sh" ]
0 commit comments