FROM python:3.12-slim

ARG SCRCPY_VERSION=3.1
ARG TARGETARCH

RUN apt-get update && apt-get install -y --no-install-recommends \
    android-tools-adb \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    curl \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /opt/scrcpy && \
    curl -fsSL "https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VERSION}/scrcpy-server-v${SCRCPY_VERSION}" \
    -o /opt/scrcpy/scrcpy-server.jar

WORKDIR /app

COPY sdks/bridge-client-python /build/bridge-client-python
RUN pip install --no-cache-dir /build/bridge-client-python

COPY agents/device-agent /app
RUN pip install --no-cache-dir '.[ai]'

ENV SCRCPY_SERVER_PATH=/opt/scrcpy/scrcpy-server.jar

ENTRYPOINT ["python", "-m", "device_agent"]
