# =============================================================================
# textual-docs-mcp — Multi-stage Docker build
# =============================================================================
# Image: ghcr.io/diaz3618/textual-docs-mcp
#
# Build:  docker build -t textual-docs-mcp .
# Run:    docker run -i textual-docs-mcp
#
# The server uses STDIO transport by default — connect via MCP client.
# =============================================================================

FROM python:3.12-slim AS builder

WORKDIR /app

RUN pip install --no-cache-dir uv

COPY pyproject.toml README.md LICENSE ./
COPY src/ ./src/

RUN uv pip install --system build && python -m build --wheel

# ---------------------------------------------------------------------------
# Runtime stage
# ---------------------------------------------------------------------------
FROM python:3.12-slim AS runtime

LABEL org.opencontainers.image.source="https://github.com/diaz3618/textual-docs-mcp"
LABEL org.opencontainers.image.description="MCP server for Textual TUI documentation"
LABEL org.opencontainers.image.licenses="MIT"

WORKDIR /app

RUN useradd --create-home --shell /bin/bash appuser

COPY --from=builder /app/dist/*.whl /tmp/
RUN pip install --no-cache-dir /tmp/*.whl && rm -rf /tmp/*.whl

USER appuser

ENTRYPOINT ["textual-docs-mcp"]
