FROM python:3.14-slim

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Install packages needed to build common Python packages and Postgres client
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    gcc \
    git \
    libpq-dev \
    pkg-config \
    libcairo2-dev \
    libgdk-pixbuf-xlib-2.0-0 \
    libgdk-pixbuf-xlib-2.0-dev \
    libjpeg-dev \
    zlib1g-dev \
    wget \
    ca-certificates \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

# Install Python deps first for better caching
COPY requirements.txt /usr/src/app/
RUN pip install --upgrade pip setuptools wheel && \
    pip install --no-cache-dir -r requirements.txt

# Copy project (will be shadowed by volume in development)
COPY . /usr/src/app

WORKDIR /usr/src/app

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
