# syntax=docker/dockerfile:1.7
FROM python:3.12-slim AS base

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

# Runtime deps: stockfish for eval, tmux for the agent panes, curl for the
# in-container vendor fetch step.
RUN apt-get update && apt-get install -y --no-install-recommends \
    stockfish \
    tmux \
    curl \
    ca-certificates \
    procps \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy everything first — pip install -e needs src/ai_chess to exist at
# build time so the editable wheel can find the package.
COPY pyproject.toml README.md ./
COPY src ./src
COPY public ./public
COPY scripts ./scripts
COPY docs ./docs

# Python deps (editable install of the project itself + dev tools)
RUN pip install hatchling \
 && pip install -e ".[dev]"

# Vendor JS/CSS at build time so the container is fully self-contained.
RUN chmod +x scripts/*.sh && ./scripts/fetch-vendor.sh

# Runtime artefacts (games/, logs/, config/) — keep as named mountable dirs.
RUN mkdir -p games logs config

EXPOSE 7833
CMD ["python", "-m", "ai_chess"]
