Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- Dockerfile +6 -9
- app.py +18 -9
Dockerfile
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install curl for health checks
|
| 6 |
-
RUN apt-get update && apt-get install -y --no-install-recommends
|
| 7 |
-
curl \
|
| 8 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
# Copy
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
|
@@ -20,13 +18,12 @@ COPY app.py .
|
|
| 20 |
# Expose port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
#
|
| 24 |
ENV PYTHONUNBUFFERED=1
|
| 25 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 26 |
|
| 27 |
# Health check
|
| 28 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3
|
| 29 |
-
CMD curl -f http://localhost:7860/ || exit 1
|
| 30 |
|
| 31 |
-
# Run MCP Server
|
| 32 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install curl for health checks
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Copy and install dependencies
|
| 9 |
COPY requirements.txt .
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
|
|
|
|
| 18 |
# Expose port
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
+
# Environment variables
|
| 22 |
ENV PYTHONUNBUFFERED=1
|
| 23 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 24 |
|
| 25 |
# Health check
|
| 26 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 CMD curl -f http://localhost:7860/ || exit 1
|
|
|
|
| 27 |
|
| 28 |
+
# Run MCP Server
|
| 29 |
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -1,12 +1,21 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
This file is required by HF Space as the main application entry point.
|
| 4 |
-
"""
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
# Entry point for Hugging Face Space
|
| 9 |
if __name__ == "__main__":
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# Configure for HF Space port 7860
|
| 5 |
+
os.environ["UVICORN_PORT"] = "7860"
|
| 6 |
+
os.environ["UVICORN_HOST"] = "0.0.0.0"
|
| 7 |
|
|
|
|
| 8 |
if __name__ == "__main__":
|
| 9 |
+
import uvicorn
|
| 10 |
+
|
| 11 |
+
# Import the FastMCP server
|
| 12 |
+
from mcp_server_fastmcp import mcp
|
| 13 |
+
|
| 14 |
+
# Run with custom port
|
| 15 |
+
# We need to monkeypatch uvicorn settings
|
| 16 |
+
uvicorn.run(
|
| 17 |
+
"mcp_server_fastmcp:mcp",
|
| 18 |
+
host="0.0.0.0",
|
| 19 |
+
port=7860,
|
| 20 |
+
log_level="info"
|
| 21 |
+
)
|