# syntax=docker/dockerfile:1.7
FROM python:3.12-slim AS build
WORKDIR /src
RUN pip install --no-cache-dir build
COPY pyproject.toml README.md ./
COPY src ./src
RUN python -m build --wheel --outdir /dist

FROM python:3.12-slim
RUN useradd -r -u 1001 -m thruk
WORKDIR /app
COPY --from=build /dist/*.whl /tmp/
RUN pip install --no-cache-dir /tmp/*.whl && rm -f /tmp/*.whl

# Embed the Docker MCP Gateway catalog metadata so that self-configured
# deployments (docker:// references) expose correct tool argument schemas.
# Without this label the gateway uses empty schemas and strips all arguments
# before forwarding tool calls, causing Field required errors at runtime.
# The label value is generated by scripts/gen_metadata.py and injected at
# build time via --build-arg SERVER_METADATA="$(python scripts/gen_metadata.py)".
ARG SERVER_METADATA="{}"
LABEL io.docker.server.metadata="$SERVER_METADATA"

USER thruk
ENV PYTHONUNBUFFERED=1
# Default = stdio transport (Docker MCP Gateway / Claude Desktop / LibreChat).
# For HTTP/Streamable-HTTP, override CMD: ["--listen", "8001"]
EXPOSE 8001
ENTRYPOINT ["thruk-mcp"]
CMD []
