forked from opendatahub-io/rhoai-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
70 lines (52 loc) · 2.65 KB
/
Copy pathContainerfile
File metadata and controls
70 lines (52 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Multi-stage Containerfile for RHOAI MCP Server
# Optimized for Podman with Red Hat UBI base images
# Supports all transport modes (stdio, SSE, streamable-http)
#
# Build with: podman build -f Containerfile -t rhoai-mcp .
# =============================================================================
# Stage 1: Builder - Install dependencies with uv
# =============================================================================
ARG BASE_IMAGE=quay.io/opendatahub/odh-midstream-python-base-3-12:1.20260625.1@sha256:e50b08950097ed95f137e6899696911422166ef539153bb08c15ee36b05a54f0
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} AS builder
# Copy project files for dependency resolution
COPY pyproject.toml uv.lock README.md ./
# Copy source code
COPY src/ ./src/
# Install dependencies and package
RUN uv sync --frozen --no-dev
# =============================================================================
# Stage 2: Runtime - Minimal production image
# =============================================================================
FROM --platform=${TARGETPLATFORM} ${BASE_IMAGE} AS runtime
# Labels for container metadata
LABEL org.opencontainers.image.title="RHOAI MCP Server"
LABEL org.opencontainers.image.description="MCP server for Red Hat OpenShift AI - enables AI agents to interact with RHOAI environments"
LABEL org.opencontainers.image.vendor="Red Hat"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/opendatahub-io/rhoai-mcp"
# Copy virtual environment from builder
COPY --from=builder /opt/app-root/src/.venv /opt/app-root/src/.venv
# Copy source code (needed for editable installs)
COPY --from=builder /opt/app-root/src/src /opt/app-root/src/src
# Add virtual environment to PATH
ENV PATH="/opt/app-root/src/.venv/bin:$PATH"
# Environment variables with container-friendly defaults
# Transport: default to stdio for Claude Desktop compatibility
ENV RHOAI_MCP_TRANSPORT="stdio"
# HTTP binding: use 0.0.0.0 for container networking
ENV RHOAI_MCP_HOST="0.0.0.0"
ENV RHOAI_MCP_PORT="8000"
# Auth: default to auto-detection
ENV RHOAI_MCP_AUTH_MODE="auto"
# Logging: default to INFO
ENV RHOAI_MCP_LOG_LEVEL="INFO"
# Expose port for HTTP transports (SSE, streamable-http)
EXPOSE 8000
# Health check for HTTP transports
# Note: Only works with SSE/streamable-http, not stdio
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8000/health', timeout=5)" || exit 0
# Default entrypoint runs the MCP server
ENTRYPOINT ["rhoai-mcp"]
# Default to stdio transport (can be overridden with --transport sse|streamable-http)
CMD ["--transport", "stdio"]