FROM python:3.10-slim | |
# 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/* | |
# Set working directory | |
WORKDIR /app | |
# Pre-install large packages to reduce memory pressure | |
RUN pip install --no-cache-dir torch==2.0.0 torchaudio==2.0.1 | |
# Copy requirements and install with force-reinstall | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir --force-reinstall -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"] |