Spaces:
Sleeping
Sleeping
Fix: Run ES as elasticsearch user with gosu
Browse files- Dockerfile +15 -9
Dockerfile
CHANGED
|
@@ -2,19 +2,25 @@ FROM argilla/argilla-server:latest
|
|
| 2 |
|
| 3 |
USER root
|
| 4 |
|
| 5 |
-
# Install Java
|
| 6 |
-
RUN apt-get update && apt-get install -y openjdk-17-jre-headless curl procps && rm -rf /var/lib/apt/lists/*
|
| 7 |
|
| 8 |
-
# Download
|
| 9 |
-
RUN curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.11.0-linux-x86_64.tar.gz && tar -xzf elasticsearch-8.11.0-linux-x86_64.tar.gz -C /opt && rm elasticsearch-8.11.0-linux-x86_64.tar.gz
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
RUN
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
ENV ARGILLA_ELASTICSEARCH=http://127.0.0.1:9200
|
| 16 |
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
# Start ES then Argilla
|
| 20 |
-
CMD /opt/elasticsearch-8.11.0/bin/elasticsearch -d -p /tmp/es.pid && sleep
|
|
|
|
| 2 |
|
| 3 |
USER root
|
| 4 |
|
| 5 |
+
# Install Java and tools
|
| 6 |
+
RUN apt-get update && apt-get install -y openjdk-17-jre-headless curl procps gosu && rm -rf /var/lib/apt/lists/*
|
| 7 |
|
| 8 |
+
# Download Elasticsearch
|
| 9 |
+
RUN curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.11.0-linux-x86_64.tar.gz && tar -xzf elasticsearch-8.11.0-linux-x86_64.tar.gz -C /opt && rm elasticsearch-8.11.0-linux-x86_64.tar.gz
|
| 10 |
|
| 11 |
+
# Create elasticsearch user and set permissions
|
| 12 |
+
RUN useradd -m -s /bin/bash elasticsearch && chown -R elasticsearch:elasticsearch /opt/elasticsearch-8.11.0 && mkdir -p /var/lib/argilla && chown -R argilla:argilla /var/lib/argilla
|
| 13 |
|
| 14 |
+
# Configure ES for minimal memory and no security
|
| 15 |
+
RUN echo "xpack.security.enabled: false" >> /opt/elasticsearch-8.11.0/config/elasticsearch.yml && echo "xpack.security.enrollment.enabled: false" >> /opt/elasticsearch-8.11.0/config/elasticsearch.yml && echo "discovery.type: single-node" >> /opt/elasticsearch-8.11.0/config/elasticsearch.yml && echo "network.host: 127.0.0.1" >> /opt/elasticsearch-8.11.0/config/elasticsearch.yml && echo "bootstrap.memory_lock: false" >> /opt/elasticsearch-8.11.0/config/elasticsearch.yml
|
| 16 |
+
|
| 17 |
+
# Set ES memory to 512MB
|
| 18 |
+
RUN echo "-Xms512m" >> /opt/elasticsearch-8.11.0/config/jvm.options && echo "-Xmx512m" >> /opt/elasticsearch-8.11.0/config/jvm.options
|
| 19 |
+
|
| 20 |
+
ENV ES_JAVA_OPTS="-Xms512m -Xmx512m"
|
| 21 |
ENV ARGILLA_ELASTICSEARCH=http://127.0.0.1:9200
|
| 22 |
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
+
# Start ES as elasticsearch user, then Argilla
|
| 26 |
+
CMD gosu elasticsearch /opt/elasticsearch-8.11.0/bin/elasticsearch -d -p /tmp/es.pid && sleep 45 && python -m argilla_server database migrate && python -m argilla_server start --host 0.0.0.0 --port 7860
|