mwtuni commited on
Commit
fd80d38
·
1 Parent(s): 83ae0ca

local pass

Browse files
Files changed (3) hide show
  1. Dockerfile +11 -5
  2. README.md +3 -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
- # System deps
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
- ffmpeg libsm6 libxext6 libgl1 git git-lfs \
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/* \
10
  && git lfs install
11
 
12
  WORKDIR /app
13
 
14
- # ---------- Cache heavy PIP layer ----------
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
- # ---------- Only copy app code ----------
21
  COPY . .
22
 
23
  EXPOSE 7860
24
  ENV PORT=7860
25
 
26
- CMD ["python", "app.py"]
 
 
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: gradio
7
- app_file: app.py
8
  pinned: false
9
  python_version: "3.10"
 
10
  license: mit
11
- short_description: Digital avatar with MCP, images, and low-latency chat
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 /ui so FastAPI "/" stays alive
457
  # ----------------------------------------------------
458
 
459
  app = gr.mount_gradio_app(fastapi_app, ui, path="/")
460
 
461
- # Always run uvicorn in Docker/HF
462
- if __name__ == "__main__":
 
 
 
 
 
 
 
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
+