| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for layer caching | |
| COPY mcp_server/requirements.txt /app/requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY mcp_server/ /app/mcp_server/ | |
| COPY kg/ /app/kg/ | |
| COPY docs/ /app/docs/ | |
| # Set environment variables | |
| ENV PORT=7860 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| # Expose port 7860 (Hugging Face Spaces standard) | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Run the server | |
| CMD ["python", "-m", "uvicorn", "mcp_server.server:app", "--host", "0.0.0.0", "--port", "7860"] | |