FROM python:3.12-slim

WORKDIR /app

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# 1) Install dependencies only (large layer, cached unless pyproject.toml changes)
COPY pyproject.toml .python-version README.md ./
RUN mkdir -p src/specwright && touch src/specwright/__init__.py && \
    uv pip install --system -e ".[dev]" && \
    rm -rf src/specwright

# 2) Copy source (small layers, change frequently)
COPY src/ src/
COPY templates/ templates/
COPY static/ static/

# 3) Re-create editable install link (fast, deps already installed)
RUN uv pip install --system --no-deps -e .

EXPOSE 3000

ENTRYPOINT ["uvicorn", "specwright.main:app", "--host", "0.0.0.0", "--port", "3000", "--reload", "--reload-dir", "/app/src"]
