Simplify ElasticSearch to make it more robust
[ta/caas-logging.git] / docker-build / elasticsearch / Dockerfile
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 FROM scratch
16 ADD centos-7-docker.tar.xz /
17 CMD ["/bin/bash"]
18 MAINTAINER Levente Kale <levente.kale@nokia.com>
19
20 ARG VERSION
21
22 ENV PATH /usr/share/elasticsearch/bin:$PATH
23 ENV JAVA_HOME /usr/lib/jvm/jre-13-openjdk
24 ENV DOWNLOAD_URL "https://artifacts.elastic.co/downloads/elasticsearch"
25 ENV ES_TARBAL "${DOWNLOAD_URL}/elasticsearch-oss-${VERSION}-linux-x86_64.tar.gz"
26
27 WORKDIR /usr/share/elasticsearch
28
29 RUN groupadd -g 202 elasticsearch \
30 &&  adduser -u 202 -g 202 -d /usr/share/elasticsearch elasticsearch \
31 &&  yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
32 &&  yum install -y --setopt=skip_missing_names_on_install=False \
33       java-latest-openjdk-headless \
34       unzip \
35       which \
36       coreutils \
37       cronie \
38       supervisor \
39 &&  yum clean all \
40 &&  curl -fsSL ${ES_TARBAL} | tar zx --strip-components=1 \
41 &&  chown -R elasticsearch:elasticsearch /usr/share/elasticsearch \
42 # workaround for Elasticsearch: this way ES can list the used plugins, and remove the jdk folder (open jdk slimmer)
43 &&  cp -al /usr/share/elasticsearch/modules/* /usr/share/elasticsearch/plugins/ \
44 &&  rm -rf /usr/share/elasticsearch/jdk \
45 # workaround end
46 &&  sed '/GC logging/Q' -i /usr/share/elasticsearch/config/jvm.options   # disable GC logging
47
48 COPY elasticsearch-logrotate.sh /etc/cron.hourly/
49 COPY elasticsearch-setindex.sh /usr/share/elasticsearch/
50 COPY log4j2.properties /usr/share/elasticsearch/config/
51 COPY supervisord.conf /etc/