File size: 1,268 Bytes
fdf2d5a
 
 
 
 
 
 
 
7c245b4
fdf2d5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c245b4
fdf2d5a
 
 
 
 
 
7c245b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM python:3.9-slim

# Exposing ports
EXPOSE 9200

RUN apt update
RUN apt -y install python3.9-dev gcc gnupg apache2-utils systemctl curl sudo vim


# Create new user for starting elasticsearch
#RUN useradd -ms /bin/bash user -p "$(openssl passwd -1 ubuntu)"
#RUN echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

# Install Elasticsearch
RUN curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
RUN apt update
RUN apt -y install elasticsearch=8.5.3

# Disable security in elasticsearch configuration
RUN sed -i "s/xpack.security.enabled: true/xpack.security.enabled: false/g" /etc/elasticsearch/elasticsearch.yml
RUN sed -i "s/cluster.initial_master_nodes/#cluster.initial_master_nodes/g" /etc/elasticsearch/elasticsearch.yml
RUN sed -i '$ a\cluster.routing.allocation.disk.threshold_enabled: false' /etc/elasticsearch/elasticsearch.yml

# Create elasticsearch directory and change ownership
RUN mkdir -p /var/run/elasticsearch
RUN chown -R 1000:1000 /var/run/elasticsearch

# Start elasticsearch
RUN echo "Starting Elasticsearch"
RUN systemctl daemon-reload
RUN systemctl enable elasticsearch

CMD ["elasticsearch"]