FROM python:3.12-slim WORKDIR /app # Install system dependencies needed for OpenCV, PIL, and PyTorch RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libgl1 \ libglib2.0-0 \ curl \ && rm -rf /var/lib/apt/lists/* # Copy dependency specifications COPY requirements.txt ./ RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu && \ pip install --no-cache-dir open_clip_torch google-genai pillow numpy # Copy backend code COPY . /app/backend WORKDIR /app/backend ENV PYTHONUNBUFFERED=1 ENV PORT=8000 EXPOSE 8000 CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000}"]