FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Install mizan-core (shared Python protocol primitives) first
COPY cores/mizan-python/ /app/mizan-core/
RUN pip install --no-cache-dir /app/mizan-core

# Install mizan from local source with channels support
COPY backends/mizan-django/ /app/django/
RUN pip install --no-cache-dir /app/django[channels] daphne

# Copy example app
COPY examples/django-react-site/backend/ /app/example/

WORKDIR /app/example

EXPOSE 8000

CMD ["sh", "-c", "python manage.py migrate --run-syncdb && daphne -b 0.0.0.0 -p 8000 testapp.asgi:application"]
