FROM python:3.10-slim | |
# Set environment variables to reduce pip caching and ensure consistent builds | |
ENV PIP_NO_CACHE_DIR=1 | |
ENV PYTHONUNBUFFERED=1 | |
# Install system dependencies from apt.txt | |
COPY apt.txt . | |
RUN apt-get update && \ | |
xargs -a apt.txt apt-get install -y && \ | |
rm -rf /var/lib/apt/lists/* | |
# Upgrade pip to avoid dependency resolution issues | |
RUN pip install --upgrade pip | |
# Set working directory | |
WORKDIR /app | |
# Copy requirements and install | |
COPY requirements.txt . | |
RUN pip install -r requirements.txt | |
# Copy app code | |
COPY app.py . | |
# Expose port for Hugging Face Spaces | |
EXPOSE 7860 | |
# Run Streamlit app | |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] |