# ---- base: runtime image, shared by prod and dev ----
FROM python:3.11-slim AS base

WORKDIR /app

# Install curl for healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY app /app/app
COPY src /app/src

# Install the pargo-auth package locally (for imports)
COPY pyproject.toml README.md ./
RUN pip install -e .

EXPOSE 8040

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8040"]

# ---- dev: base + test/dev deps (pytest, ...), for local use only ----
# docker-compose.local.yml builds this via `target: dev`. Inherits base's CMD,
# so `docker compose up` runs the service AND the image can run the test suite
# with no manual pip install — self-contained.
FROM base AS dev
RUN pip install --no-cache-dir -e ".[dev]"

# ---- prod: lean runtime, the default build target ----
# Last stage, so a build with no `target` (prod CI) resolves here and gets NO
# dev deps. Identical to the old single-stage image.
FROM base AS prod
