Skip to content

Commit f248ae2

Browse files
committed
Update Dockerfile
Updating opensearch dockerfile
1 parent 8fa8192 commit f248ae2

File tree

1 file changed

+26
-89
lines changed

1 file changed

+26
-89
lines changed

etc/opensearch/2.x/Dockerfile

Lines changed: 26 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -12,100 +12,37 @@
1212

1313

1414
########################### Stage 0 ########################
15-
FROM amazonlinux:2 AS linux_stage_0
15+
FROM opensearchproject/opensearch:latest
1616

17-
ARG UID=1000
18-
ARG GID=1000
19-
ARG TEMP_DIR=/tmp/opensearch
20-
ARG OPENSEARCH_HOME=/usr/share/opensearch
21-
ARG OPENSEARCH_PATH_CONF=$OPENSEARCH_HOME/config
22-
ARG SECURITY_PLUGIN_DIR=$OPENSEARCH_HOME/plugins/opensearch-security
23-
ARG PERFORMANCE_ANALYZER_PLUGIN_CONFIG_DIR=$OPENSEARCH_PATH_CONF/opensearch-performance-analyzer
24-
ARG OS_VERSION=2.5.0
25-
# Update packages
26-
# Install the tools we need: tar and gzip to unpack the OpenSearch tarball, and shadow-utils to give us `groupadd` and `useradd`.
27-
# Install which to allow running of securityadmin.sh
28-
RUN yum update -y && yum install -y tar gzip shadow-utils which && yum clean all
17+
# Set the working directory
18+
WORKDIR /usr/share/opensearch/
2919

30-
# Create an opensearch user, group, and directory
31-
RUN groupadd -g $GID opensearch && \
32-
adduser -u $UID -g $GID -d $OPENSEARCH_HOME opensearch && \
33-
mkdir $TEMP_DIR
20+
# Create the .utm_geoip folder inside the image
21+
RUN mkdir -p /usr/share/opensearch/.utm_geoip
3422

35-
RUN mkdir /usr/share/elasticsearch
36-
WORKDIR /usr/share/elasticsearch
23+
# Switch to root user to execute commands with permissions
24+
USER root
3725

38-
RUN set -eux ; \
39-
cur_arch="" ; \
40-
case "$(arch)" in \
41-
aarch64) cur_arch='arm64' ;; \
42-
x86_64) cur_arch='x64' ;; \
43-
*) echo >&2 ; echo >&2 "Unsupported architecture $(arch)" ; echo >&2 ; exit 1 ;; \
44-
esac ; \
45-
curl --retry 10 -S -L --output $TEMP_DIR/opensearch.tar.gz https://artifacts.opensearch.org/releases/bundle/opensearch/$OS_VERSION/opensearch-$OS_VERSION-linux-$cur_arch.tar.gz; \
46-
curl --output $TEMP_DIR/opensearch.pgp https://artifacts.opensearch.org/publickeys/opensearch.pgp; \
47-
gpg --import $TEMP_DIR/opensearch.pgp; \
48-
curl --output $TEMP_DIR/opensearch.tar.gz.sig https://artifacts.opensearch.org/releases/bundle/opensearch/$OS_VERSION/opensearch-$OS_VERSION-linux-$cur_arch.tar.gz.sig; \
49-
gpg --verify $TEMP_DIR/opensearch.tar.gz.sig $TEMP_DIR/opensearch.tar.gz;
26+
# Download the utm-geoip.tar.xz file and extract it
27+
RUN yum update -y && \
28+
yum install -y xz wget && \
29+
wget -O /tmp/utm-geoip.tar.xz https://cdn.utmstack.com/geoip/utm-geoip.tar.xz && \
30+
tar -xJf /tmp/utm-geoip.tar.xz -C /usr/share/opensearch/.utm_geoip && \
31+
rm /tmp/utm-geoip.tar.xz && \
32+
yum remove -y xz wget && \
33+
yum clean all && \
34+
rm -rf /var/cache/yum && \
35+
rm -rf /usr/share/man /usr/share/doc /usr/share/info /tmp/* /var/tmp/*
5036

51-
RUN tar --warning=no-timestamp -zxf $TEMP_DIR/opensearch.tar.gz -C $OPENSEARCH_HOME --strip-components=1 && \
52-
mkdir -p $OPENSEARCH_HOME/data && chown -Rv $UID:$GID $OPENSEARCH_HOME/data && \
53-
if [[ -d $SECURITY_PLUGIN_DIR ]] ; then chmod -v 750 $SECURITY_PLUGIN_DIR/tools/* ; fi && \
54-
rm -rf $TEMP_DIR
37+
# Assign permissions and ownership to the extracted folder
38+
RUN chmod -R 777 /usr/share/opensearch/.utm_geoip && \
39+
chown -R opensearch:opensearch /usr/share/opensearch/.utm_geoip
5540

56-
COPY config/* $OPENSEARCH_PATH_CONF/
57-
COPY bin/* $OPENSEARCH_HOME/
58-
RUN if [[ -d $PERFORMANCE_ANALYZER_PLUGIN_CONFIG_DIR ]] ; then mv $OPENSEARCH_PATH_CONF/performance-analyzer.properties $PERFORMANCE_ANALYZER_PLUGIN_CONFIG_DIR/ ; fi
59-
########################### Stage 1 ########################
60-
# Copy working directory to the actual release docker images
61-
FROM amazonlinux:2
41+
# Restore OpenSearch user
42+
USER opensearch
6243

63-
ARG UID=1000
64-
ARG GID=1000
65-
ARG OPENSEARCH_HOME=/usr/share/opensearch
66-
ARG OS_VERSION=2.5.0
44+
# Expose default OpenSearch ports
45+
EXPOSE 9200 9600
6746

68-
RUN yum update -y && yum install -y tar gzip shadow-utils which && yum clean all
69-
70-
# Create an opensearch user, group
71-
RUN groupadd -g $GID opensearch && \
72-
adduser -u $UID -g $GID -d $OPENSEARCH_HOME opensearch
73-
74-
# Copy from Stage0
75-
COPY --from=linux_stage_0 --chown=$UID:$GID $OPENSEARCH_HOME $OPENSEARCH_HOME
76-
WORKDIR $OPENSEARCH_HOME
77-
78-
# Set $JAVA_HOME
79-
RUN echo "export JAVA_HOME=$OPENSEARCH_HOME/jdk" >> /etc/profile.d/java_home.sh && \
80-
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile.d/java_home.sh
81-
ENV JAVA_HOME=$OPENSEARCH_HOME/jdk
82-
ENV PATH=$PATH:$JAVA_HOME/bin:$OPENSEARCH_HOME/bin
83-
84-
# Add k-NN lib directory to library loading path variable
85-
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$OPENSEARCH_HOME/plugins/opensearch-knn/lib"
86-
87-
# Change user
88-
USER $UID
89-
90-
91-
# Setup OpenSearch
92-
# Disable security demo installation during image build, and allow user to disable during startup of the container
93-
# Enable security plugin during image build, and allow user to disable during startup of the container
94-
ARG DISABLE_INSTALL_DEMO_CONFIG=true
95-
ARG DISABLE_SECURITY_PLUGIN=false
96-
RUN ./opensearch-onetime-setup.sh
97-
98-
EXPOSE 9200 9300 9600 9650
99-
100-
# Label
101-
LABEL org.label-schema.schema-version="1.0" \
102-
org.label-schema.name="opensearch" \
103-
org.label-schema.version="$OS_VERSION" \
104-
org.label-schema.url="https://opensearch.org" \
105-
org.label-schema.vcs-url="https://github.com/OpenSearch" \
106-
org.label-schema.license="Apache-2.0" \
107-
org.label-schema.vendor="OpenSearch"
108-
109-
# CMD to run
110-
ENTRYPOINT ["./opensearch-docker-entrypoint.sh"]
111-
CMD ["opensearch"]
47+
# Startup command
48+
CMD ["/usr/share/opensearch/opensearch-docker-entrypoint.sh"]

0 commit comments

Comments
 (0)