# Sandroid container image (best effort / community supported).
#
# The emulator itself runs on the HOST; the container only runs Sandroid and
# talks to the host's adb server. Build from the repository root:
#
#   docker build -t sandroid -f docker/dockerfile .
#
# Run (Linux, host networking so the container reaches the host adb server):
#
#   docker run --rm -it --network host \
#       -v "$PWD/results:/sandroid/results" \
#       -v "$HOME/.config/sandroid:/root/.config/sandroid" sandroid
#
# On Docker Desktop (macOS/Windows) use
#   -e ADB_SERVER_SOCKET=tcp:host.docker.internal:5037
# and start the host adb server with `adb -a nodaemon server` so it accepts
# non-local connections.
#
# Dependencies come exclusively from pyproject.toml -- do not add a separate
# requirements file (it drifts from the real pins).

FROM python:3.12-slim-bookworm

ENV DEBIAN_FRONTEND=noninteractive \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

RUN apt-get update && apt-get install -y --no-install-recommends \
        adb \
        build-essential \
        ca-certificates \
        libxml2-dev \
        libxslt1-dev \
        sqlite3 \
        tzdata && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /sandroid

# Install Sandroid (with the optional static-analysis + AI extras) from source.
COPY pyproject.toml README.md LICENSE /sandroid/
COPY src /sandroid/src
RUN python -m pip install "/sandroid[full]"

COPY ground_truth.apk /sandroid/ground_truth.apk
COPY assets/sandroid_logo.png /sandroid/assets/sandroid_logo.png
COPY docker/docker_welcome_message /root/welcome

ENV DEBIAN_FRONTEND=dialog

CMD ["sh", "-c", "printf '%b\\n\\n' \"$(cat /root/welcome)\" && exec bash"]
