# Reactor model — partner Dockerfile baseline.
#
# Generated by `reactor init`. Edit freely — this is just a starting point
# that gets you to a working `reactor-runtime run` container without having
# to figure out the GStreamer + PyGObject + Python setup yourself.
#
# Build:   docker build -t my-model:dev .
# Run:     docker run --rm -p 8080:8080 my-model:dev
#
# The system packages mirror scripts/gstreamer-install.sh in the
# reactor_runtime repo (Debian/Ubuntu branch); keep them in sync if the
# upstream transport requirements change.

FROM python:3.12-slim

# --- System dependencies --------------------------------------------------
# GStreamer + PyGObject build deps. --no-install-recommends keeps the
# image lean; the explicit list is required because the runtime's default
# WebRTC transport (resolve_default_transport) imports PyGObject which
# pulls in libnice + the gstreamer plugin set at import time.
RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        build-essential \
        cmake \
        pkg-config \
        gobject-introspection \
        libcairo2 \
        libcairo2-dev \
        libglib2.0-0 \
        libgirepository-2.0-dev \
        gir1.2-gstreamer-1.0 \
        gir1.2-gst-plugins-base-1.0 \
        gir1.2-gst-plugins-bad-1.0 \
        gstreamer1.0-plugins-base \
        gstreamer1.0-plugins-good \
        gstreamer1.0-plugins-bad \
        gstreamer1.0-plugins-ugly \
        gstreamer1.0-libav \
        gstreamer1.0-nice \
        gstreamer1.0-tools \
        libnice10 \
    && rm -rf /var/lib/apt/lists/*

# --- Python dependencies --------------------------------------------------
# We use uv for fast, reproducible installs. --system installs into the
# image's interpreter directly: there's no second venv to manage inside a
# container that already has hermetic isolation.
RUN pip install --no-cache-dir uv

WORKDIR /app

# Copy requirements first so layer caching kicks in on source-only edits.
COPY requirements.txt /app/requirements.txt
RUN uv pip install --system --no-cache -r /app/requirements.txt

# --- Model code -----------------------------------------------------------
# Bring in the model sources and configuration. Add additional COPY lines
# below if your project grows extra directories (data/, assets/, ...).
COPY *.py /app/
COPY *.yaml /app/

EXPOSE 8080

# `reactor-runtime run` reads reactor.yaml from /app, instantiates the
# model class declared under runtime.import, and starts serving.
CMD ["reactor-runtime", "run"]
