FROM python:3.12-slim AS runtime

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    ESAALAT_MCP_HOST=0.0.0.0 \
    ESAALAT_MCP_PORT=8001

WORKDIR /app

# Build from the package itself so the installed entry points and UI assets are
# exactly the released wheel contents. The source tree is small; no compiler or
# git client is needed by the runtime dependencies.
COPY pyproject.toml README.md ./
COPY src ./src
RUN pip install --no-cache-dir . \
    && useradd --uid 10001 --create-home --shell /usr/sbin/nologin mcp

USER mcp

EXPOSE 8001

# Docker/Dokploy can use this instead of an HTTP probe. urllib is part of the
# base image, so the runtime does not need curl just for a health check.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8001/healthz', timeout=3)"]

CMD ["esaalat-mcp-http"]
