# Timmy Time — unified image (CI · dev · production)
#
# All deps pre-installed from poetry.lock; project mounted at runtime.
#
#   Build: docker build -t timmy-time .
#   CI:    act_runner mounts checkout automatically
#   Dev:   docker run -v .:/app -p 8000:8000 timmy-time tox -e dev
#   Run:   docker run -v .:/app -p 8000:8000 timmy-time

FROM python:3.11-slim

# ── System + build prereqs ────────────────────────────────────────────────────
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       gcc git bash curl fonts-dejavu-core nodejs \
    && rm -rf /var/lib/apt/lists/*

# ── Python tooling ────────────────────────────────────────────────────────────
RUN pip install --no-cache-dir poetry tox

# ── Pre-install all project deps (source mounted at runtime) ──────────────────
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false \
    && poetry install --with dev --no-root --no-interaction \
    && rm pyproject.toml poetry.lock

# ── Environment ───────────────────────────────────────────────────────────────
ENV PYTHONPATH=/app/src \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

EXPOSE 8000
CMD ["uvicorn", "dashboard.app:app", "--host", "0.0.0.0", "--port", "8000"]
