Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +32 -54
Dockerfile
CHANGED
@@ -1,40 +1,35 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
# Install
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
curl \
|
6 |
-
openjdk-11-jdk \
|
7 |
python3 \
|
8 |
python3-pip \
|
9 |
wget \
|
10 |
-
apt-transport-https \
|
11 |
-
gnupg \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
# Install Elasticsearch
|
15 |
ENV ES_VERSION=8.8.0
|
16 |
-
RUN curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-
|
17 |
-
tar -xzf elasticsearch-
|
18 |
-
mv elasticsearch
|
19 |
-
rm elasticsearch-
|
20 |
-
|
21 |
-
#
|
22 |
-
RUN echo "discovery.type: single-node
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
#
|
27 |
-
|
28 |
-
|
29 |
-
# Create non-root user for running the services
|
30 |
-
RUN useradd -m -u 1000 appuser
|
31 |
-
RUN mkdir -p /app /usr/share/elasticsearch/data && \
|
32 |
chown -R appuser:appuser /app /usr/share/elasticsearch
|
33 |
|
34 |
-
#
|
35 |
WORKDIR /app
|
36 |
|
37 |
-
# Copy
|
38 |
COPY --chown=appuser:appuser app.py streamlit.py requirements.txt ./
|
39 |
COPY --chown=appuser:appuser chunking ./chunking
|
40 |
COPY --chown=appuser:appuser embeddings ./embeddings
|
@@ -43,43 +38,26 @@ COPY --chown=appuser:appuser elastic ./elastic
|
|
43 |
COPY --chown=appuser:appuser file_processing.py ./
|
44 |
COPY --chown=appuser:appuser ingestion.py ./
|
45 |
|
46 |
-
#
|
47 |
-
|
48 |
-
|
49 |
-
# Install Python dependencies
|
50 |
-
RUN pip3 install -r requirements.txt
|
51 |
|
52 |
-
#
|
53 |
-
ENV
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
# Expose required ports
|
61 |
EXPOSE 9200 7860
|
62 |
|
63 |
# Switch to non-root user
|
64 |
USER appuser
|
65 |
|
66 |
-
#
|
67 |
-
|
68 |
-
|
69 |
-
/usr/share/elasticsearch/bin/elasticsearch &\n\
|
70 |
-
\n\
|
71 |
-
# Wait for Elasticsearch to become available\n\
|
72 |
-
echo "Waiting for Elasticsearch to start..."\n\
|
73 |
-
until curl -s http://localhost:9200 > /dev/null; do\n\
|
74 |
-
sleep 2\n\
|
75 |
-
echo "Still waiting for Elasticsearch..."\n\
|
76 |
-
done\n\
|
77 |
-
echo "Elasticsearch is up and running!"\n\
|
78 |
-
\n\
|
79 |
-
# Start Streamlit\n\
|
80 |
-
echo "Starting Streamlit application..."\n\
|
81 |
-
streamlit run /app/streamlit.py\n\
|
82 |
-
' > /app/start.sh && chmod +x /app/start.sh
|
83 |
|
84 |
-
# Command to run
|
85 |
CMD ["/app/start.sh"]
|
|
|
1 |
+
# Use a lighter base image with Java 17 (required by Elasticsearch 8.8.0)
|
2 |
+
FROM openjdk:17-jdk-slim
|
3 |
|
4 |
+
# Install dependencies
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
curl \
|
|
|
7 |
python3 \
|
8 |
python3-pip \
|
9 |
wget \
|
|
|
|
|
10 |
&& rm -rf /var/lib/apt/lists/*
|
11 |
|
12 |
# Install Elasticsearch
|
13 |
ENV ES_VERSION=8.8.0
|
14 |
+
RUN curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz && \
|
15 |
+
tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz && \
|
16 |
+
mv elasticsearch-${ES_VERSION} /usr/share/elasticsearch && \
|
17 |
+
rm elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
|
18 |
+
|
19 |
+
# Configure Elasticsearch properly
|
20 |
+
RUN echo "discovery.type: single-node\n\
|
21 |
+
xpack.security.enabled: false\n\
|
22 |
+
network.host: 0.0.0.0" > /usr/share/elasticsearch/config/elasticsearch.yml
|
23 |
+
|
24 |
+
# Create dedicated user and directories
|
25 |
+
RUN useradd -m -u 1000 appuser && \
|
26 |
+
mkdir -p /app && \
|
|
|
|
|
|
|
27 |
chown -R appuser:appuser /app /usr/share/elasticsearch
|
28 |
|
29 |
+
# Set working directory
|
30 |
WORKDIR /app
|
31 |
|
32 |
+
# Copy application files
|
33 |
COPY --chown=appuser:appuser app.py streamlit.py requirements.txt ./
|
34 |
COPY --chown=appuser:appuser chunking ./chunking
|
35 |
COPY --chown=appuser:appuser embeddings ./embeddings
|
|
|
38 |
COPY --chown=appuser:appuser file_processing.py ./
|
39 |
COPY --chown=appuser:appuser ingestion.py ./
|
40 |
|
41 |
+
# Install Python dependencies with logging fix
|
42 |
+
RUN pip3 install -r requirements.txt && \
|
43 |
+
pip3 install logback==0.2.1 # Fixes SLF4J warnings
|
|
|
|
|
44 |
|
45 |
+
# Configure environment variables
|
46 |
+
ENV ES_JAVA_OPTS="-Xms1g -Xmx1g" \
|
47 |
+
STREAMLIT_SERVER_PORT=7860 \
|
48 |
+
STREAMLIT_SERVER_HEADLESS=true \
|
49 |
+
ES_HOST=localhost \
|
50 |
+
ES_PORT=9200 \
|
51 |
+
ELASTICSEARCH_HOSTS=http://localhost:9200
|
52 |
|
53 |
+
# Expose required ports
|
54 |
EXPOSE 9200 7860
|
55 |
|
56 |
# Switch to non-root user
|
57 |
USER appuser
|
58 |
|
59 |
+
# Improved startup script
|
60 |
+
COPY --chown=appuser:appuser start.sh /app/start.sh
|
61 |
+
RUN chmod +x /app/start.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
63 |
CMD ["/app/start.sh"]
|