Update Dockerfile
Browse files- Dockerfile +27 -36
Dockerfile
CHANGED
|
@@ -1,45 +1,36 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
curl \
|
| 11 |
-
git \
|
| 12 |
-
sqlite3 \
|
| 13 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
-
|
| 15 |
-
# Create /data directory (for database, logs) and set permissions
|
| 16 |
-
RUN mkdir -p /temp && \
|
| 17 |
-
chown -R 1000:1000 /temp && \
|
| 18 |
-
chmod -R 755 /temp
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
COPY src/ ./src/
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
ENV STREAMLIT_HOME=/tmp/streamlit
|
| 34 |
-
|
| 35 |
-
# Make sure cache directories exist
|
| 36 |
-
RUN mkdir -p /tmp/hf_home /tmp/transformers_cache /tmp/xdg_cache /tmp/streamlit
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
|
| 44 |
-
#
|
| 45 |
-
|
|
|
|
| 1 |
+
# Use a lightweight Python image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set environment variables for cache directories
|
| 5 |
+
ENV HF_HOME=/tmp/huggingface_cache
|
| 6 |
+
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
|
| 7 |
+
ENV HF_HUB_CACHE=/tmp/hf_hub_cache
|
| 8 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers_cache
|
| 9 |
+
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Set the working directory in the container
|
| 12 |
+
WORKDIR /app
|
|
|
|
| 13 |
|
| 14 |
+
# Create cache directories and set permissions
|
| 15 |
+
RUN mkdir -p /tmp/huggingface_cache /tmp/transformers_cache /tmp/hf_hub_cache /tmp/sentence_transformers_cache /tmp/.streamlit && \
|
| 16 |
+
chmod -R 777 /tmp
|
| 17 |
|
| 18 |
+
# Copy the requirements file and install dependencies
|
| 19 |
+
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
+
# Copy the application files and the document
|
| 23 |
+
COPY rag_components.py .
|
| 24 |
+
COPY app.py .
|
| 25 |
+
COPY me.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
# Create a non-root user for better security in HF Spaces
|
| 28 |
+
RUN useradd -m -u 1000 user
|
| 29 |
+
RUN chown -R user:user /app /tmp
|
| 30 |
+
USER user
|
| 31 |
|
| 32 |
+
# Expose the port Streamlit runs on
|
| 33 |
+
EXPOSE 7860
|
| 34 |
|
| 35 |
+
# Command to run the Streamlit application
|
| 36 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|