local pass
Browse files- Dockerfile +11 -5
- README.md +3 -3
- app.py +12 -4
Dockerfile
CHANGED
|
@@ -3,24 +3,30 @@ FROM python:3.10-slim
|
|
| 3 |
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
PIP_NO_CACHE_DIR=1
|
| 5 |
|
| 6 |
-
#
|
| 7 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
-
ffmpeg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/* \
|
| 10 |
&& git lfs install
|
| 11 |
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
#
|
| 15 |
COPY requirements.txt .
|
| 16 |
RUN pip install --upgrade pip && \
|
| 17 |
pip install -r requirements.txt && \
|
| 18 |
pip install "gradio[oauth,mcp]==6.0.1" uvicorn spaces
|
| 19 |
|
| 20 |
-
#
|
| 21 |
COPY . .
|
| 22 |
|
| 23 |
EXPOSE 7860
|
| 24 |
ENV PORT=7860
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
| 3 |
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
PIP_NO_CACHE_DIR=1
|
| 5 |
|
| 6 |
+
# Install only required system libs
|
| 7 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
+
ffmpeg \
|
| 9 |
+
libsm6 \
|
| 10 |
+
libxext6 \
|
| 11 |
+
libgl1 \
|
| 12 |
+
git \
|
| 13 |
+
git-lfs \
|
| 14 |
&& rm -rf /var/lib/apt/lists/* \
|
| 15 |
&& git lfs install
|
| 16 |
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
+
# Install dependencies first for layer caching
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --upgrade pip && \
|
| 22 |
pip install -r requirements.txt && \
|
| 23 |
pip install "gradio[oauth,mcp]==6.0.1" uvicorn spaces
|
| 24 |
|
| 25 |
+
# Copy source
|
| 26 |
COPY . .
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
ENV PORT=7860
|
| 30 |
|
| 31 |
+
# HF Spaces expect uvicorn here — NOT inside app.py
|
| 32 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -3,12 +3,12 @@ title: Avatar MCP
|
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
| 7 |
-
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
python_version: "3.10"
|
|
|
|
| 10 |
license: mit
|
| 11 |
-
short_description: Digital avatar with
|
| 12 |
---
|
| 13 |
|
| 14 |
# Avatar Persona Space
|
|
|
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: purple
|
| 6 |
+
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
python_version: "3.10"
|
| 9 |
+
app_file: Dockerfile
|
| 10 |
license: mit
|
| 11 |
+
short_description: Digital avatar system with persistent identity, MCP tools, and image generation.
|
| 12 |
---
|
| 13 |
|
| 14 |
# Avatar Persona Space
|
app.py
CHANGED
|
@@ -453,14 +453,22 @@ with gr.Blocks() as ui:
|
|
| 453 |
# ----------------------------------------------------
|
| 454 |
# Export ASGI app for Hugging Face Spaces
|
| 455 |
# ----------------------------------------------------
|
| 456 |
-
# Mount Gradio UI at /
|
| 457 |
# ----------------------------------------------------
|
| 458 |
|
| 459 |
app = gr.mount_gradio_app(fastapi_app, ui, path="/")
|
| 460 |
|
| 461 |
-
#
|
| 462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
import uvicorn
|
| 464 |
port = int(os.getenv("PORT", "7860"))
|
| 465 |
-
print(f"Starting uvicorn on {port}...")
|
| 466 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
|
|
|
| 453 |
# ----------------------------------------------------
|
| 454 |
# Export ASGI app for Hugging Face Spaces
|
| 455 |
# ----------------------------------------------------
|
| 456 |
+
# Mount Gradio UI at "/" so FastAPI lives at /mcp/*
|
| 457 |
# ----------------------------------------------------
|
| 458 |
|
| 459 |
app = gr.mount_gradio_app(fastapi_app, ui, path="/")
|
| 460 |
|
| 461 |
+
# ----------------------------------------------------
|
| 462 |
+
# Local-only server runner
|
| 463 |
+
# ----------------------------------------------------
|
| 464 |
+
# HuggingFace Spaces sets SPACE_ID → DO NOT run uvicorn here.
|
| 465 |
+
# Dockerfile CMD will run uvicorn in HF.
|
| 466 |
+
# Local Python execution ("python app.py") WILL run uvicorn.
|
| 467 |
+
# ----------------------------------------------------
|
| 468 |
+
|
| 469 |
+
if __name__ == "__main__" and not os.getenv("SPACE_ID"):
|
| 470 |
import uvicorn
|
| 471 |
port = int(os.getenv("PORT", "7860"))
|
| 472 |
+
print(f"Starting local uvicorn on {port}...")
|
| 473 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
| 474 |
+
|