# Use official lightweight Python image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements first to leverage Docker cache COPY requirements.txt . # Install PyTorch CPU directly to save massive amounts of space (~150MB instead of ~3GB) RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu # Install remaining requirements RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application COPY src/ /app/src/ COPY models/ /app/models/ COPY app.py /app/app.py # Expose Gradio port EXPOSE 7860 # Run the application CMD ["python", "app.py"]