FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*

# Install uv
RUN pip install uv

# Copy entire aiservice directory
COPY aiservice ./

# Install dependencies
RUN uv sync

# Set environment variables
ENV ENVIRONMENT=PRODUCTION
ENV PORT=8000

EXPOSE 8000

# Use the start script that references gunicorn.conf.py
CMD ["uv", "run", "gunicorn", "-c", "gunicorn.conf.py", "aiservice.asgi:application", \
     "--bind", "0.0.0.0:8000", \
     "--timeout", "600", \
     "--workers", "2"]
