File size: 1,133 Bytes
37d2f2c 0bcb559 37d2f2c 0bcb559 37d2f2c 37eee57 37d2f2c 9d3e1f5 37d2f2c 37eee57 0bcb559 37d2f2c ecdbe25 37d2f2c 0bcb559 37d2f2c 1258b31 0bcb559 37d2f2c 1258b31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# Use a lightweight Python image
FROM python:3.9-slim
# Set environment variables for cache directories
ENV HF_HOME=/tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV HF_HUB_CACHE=/tmp/hf_hub_cache
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers_cache
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
# Set the working directory in the container
WORKDIR /app
# Create cache directories and set permissions
RUN mkdir -p /tmp/huggingface_cache /tmp/transformers_cache /tmp/hf_hub_cache /tmp/sentence_transformers_cache /tmp/.streamlit && \
chmod -R 777 /tmp
# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application files and the document
COPY rag_components.py .
COPY app.py .
COPY me.txt .
# Create a non-root user for better security in HF Spaces
RUN useradd -m -u 1000 user
RUN chown -R user:user /app /tmp
USER user
# Expose the port Streamlit runs on
EXPOSE 8501
# Command to run the Streamlit application
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|