# Late MCP HTTP Server - Railway Deployment
# Uses uv for fast, reliable dependency management

FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app

ENV MALLOC_ARENA_MAX=2

# Copy dependency files
COPY pyproject.toml uv.lock README.md ./
COPY src ./src

# Install dependencies (no dev dependencies in production)
RUN uv sync --frozen --no-dev --extra mcp

# Expose port (Railway will set PORT env var)
EXPOSE 8080

# Health check for Railway monitoring (Railway will use /health endpoint)

# Run HTTP server (Railway sets PORT env var automatically)
ENV PATH="/app/.venv/bin:$PATH"

# Exec form, no shell or `uv run`: the server is PID 1 and gets the SIGTERM a
# deploy sends, so in-flight tool calls finish. It reads PORT itself.
CMD ["late-mcp-http", "--host", "0.0.0.0"]