FROM python:3.12-slim

# Install uv (build tool). Version intentionally unpinned to track latest.
RUN pip install --no-cache-dir uv

WORKDIR /app

# Copy the full project so the build has pyproject.toml, README, uv.lock,
# and source. uv.lock pins dependency versions (e.g. mcp 1.x) so the image
# matches the tested local environment.
COPY pyproject.toml uv.lock README.md ./
COPY mensa_mcp/ /app/mensa_mcp/

# Install the package with the http extras (uvicorn + starlette) using the
# lockfile for reproducible, tested dependency versions.
RUN uv sync --frozen --extra http --no-dev

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" || exit 1

CMD ["uv", "run", "mensa-mcp", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "8000"]
