Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +56 -34
Dockerfile
CHANGED
@@ -1,35 +1,40 @@
|
|
1 |
-
|
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
|
15 |
-
tar -xzf elasticsearch
|
16 |
-
mv elasticsearch
|
17 |
-
rm elasticsearch
|
18 |
-
|
19 |
-
#
|
20 |
-
RUN echo "discovery.type: single-node\
|
21 |
-
xpack.security.enabled: false\
|
22 |
-
network.host: 0.0.0.0"
|
23 |
-
|
24 |
-
#
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
chown -R appuser:appuser /app /usr/share/elasticsearch
|
28 |
|
29 |
-
#
|
30 |
WORKDIR /app
|
31 |
|
32 |
-
# Copy
|
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,26 +43,43 @@ COPY --chown=appuser:appuser elastic ./elastic
|
|
38 |
COPY --chown=appuser:appuser file_processing.py ./
|
39 |
COPY --chown=appuser:appuser ingestion.py ./
|
40 |
|
|
|
|
|
|
|
41 |
# Install Python dependencies
|
42 |
-
RUN pip3 install -r requirements.txt
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
ENV
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
# Expose required ports
|
54 |
EXPOSE 9200 7860
|
55 |
|
56 |
# Switch to non-root user
|
57 |
USER appuser
|
58 |
|
59 |
-
# Create
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
63 |
CMD ["/app/start.sh"]
|
|
|
1 |
+
FROM ubuntu:22.04
|
|
|
2 |
|
3 |
+
# Install system dependencies
|
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-8.8.0-linux-x86_64.tar.gz && \
|
17 |
+
tar -xzf elasticsearch-8.8.0-linux-x86_64.tar.gz && \
|
18 |
+
mv elasticsearch-8.8.0 /usr/share/elasticsearch && \
|
19 |
+
rm elasticsearch-8.8.0-linux-x86_64.tar.gz
|
20 |
+
|
21 |
+
# Create elasticsearch.yml with proper YAML format
|
22 |
+
RUN echo "discovery.type: single-node" > /usr/share/elasticsearch/config/elasticsearch.yml && \
|
23 |
+
echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml && \
|
24 |
+
echo "network.host: 0.0.0.0" >> /usr/share/elasticsearch/config/elasticsearch.yml
|
25 |
+
|
26 |
+
# Set Elasticsearch environment variables
|
27 |
+
ENV ES_JAVA_OPTS="-Xms1g -Xmx1g"
|
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 |
+
# Create app directory
|
35 |
WORKDIR /app
|
36 |
|
37 |
+
# Copy your project files
|
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 |
COPY --chown=appuser:appuser file_processing.py ./
|
44 |
COPY --chown=appuser:appuser ingestion.py ./
|
45 |
|
46 |
+
# Copy ES data if needed - consider if this is actually necessary
|
47 |
+
COPY --chown=appuser:appuser es_data /usr/share/elasticsearch/data
|
48 |
+
|
49 |
# Install Python dependencies
|
50 |
+
RUN pip3 install -r requirements.txt
|
51 |
+
|
52 |
+
# Set environment variables for Streamlit
|
53 |
+
ENV STREAMLIT_SERVER_HEADLESS=true
|
54 |
+
ENV STREAMLIT_SERVER_PORT=7860
|
55 |
+
ENV STREAMLIT_SERVER_ENABLE_CORS=false
|
56 |
+
ENV ES_HOST=localhost
|
57 |
+
ENV ES_PORT=9200
|
58 |
+
ENV ELASTICSEARCH_HOSTS="http://localhost:9200"
|
59 |
+
|
60 |
+
# Expose required ports (Elasticsearch and Streamlit)
|
|
|
61 |
EXPOSE 9200 7860
|
62 |
|
63 |
# Switch to non-root user
|
64 |
USER appuser
|
65 |
|
66 |
+
# Create startup script
|
67 |
+
RUN echo '#!/bin/bash\n\
|
68 |
+
# Start Elasticsearch in the background\n\
|
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"]
|