FROM python:3.9-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y libjpeg-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

# --- SPEED OPTIMIZATION HERE ---
# We install torch from the CPU-only index to save ~700MB of download
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
# Install the rest normally
RUN pip install --no-cache-dir flask numpy Pillow

COPY server.py .

EXPOSE 5000

CMD ["python", "server.py"]
