FROM python:3.12-slim AS build
WORKDIR /build
COPY pyproject.toml README.md LICENSE THIRD_PARTY.md ./
COPY patchpilot/ ./patchpilot/
RUN python -m pip wheel --no-cache-dir --wheel-dir /wheels .

FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
RUN groupadd --gid 10001 patchpilot \
    && useradd --uid 10001 --gid 10001 --no-create-home --home-dir /tmp patchpilot
RUN --mount=type=bind,from=build,source=/wheels,target=/wheels,readonly \
    python -m pip install --no-cache-dir --no-index --find-links=/wheels patchpilot-mcp
WORKDIR /tmp
USER 10001:10001
ENTRYPOINT ["patchpilot-mcp"]
