# -- Build stage --
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder

WORKDIR /app

# Install dependencies first (cached layer)
COPY pyproject.toml uv.lock ./
RUN uv sync --no-dev --no-install-project --extra web --no-cache

# Copy source, config, and metadata, then install project
COPY README.md pyproject.toml uv.lock ./
COPY src/ src/
COPY config/ config/
RUN uv sync --no-dev --extra web --no-cache

# -- Runtime stage --
FROM python:3.13-slim-bookworm

WORKDIR /app

# Copy virtualenv and project files from builder
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/src /app/src
COPY --from=builder /app/config /app/config

# Make venv available
ENV PATH="/app/.venv/bin:$PATH"

EXPOSE 9000

CMD ["uvicorn", "excel_convert.web.app:app", "--host", "0.0.0.0", "--port", "9000"]
