Desmond-Dong commited on
Commit
e8f8f40
·
1 Parent(s): d00fdca

Make Hugging Face Spaces a static display page only

Browse files

- Dockerfile now only serves static files via FastAPI
- Added main.py for simple web server
- This makes it clear that the app runs on Reachy Mini, not Hugging Face
- Hugging Face Spaces is just for code distribution and documentation

Files changed (2) hide show
  1. Dockerfile +9 -17
  2. main.py +26 -0
Dockerfile CHANGED
@@ -4,30 +4,22 @@ FROM python:3.11-slim
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
- portaudio19-dev \
10
- build-essential \
11
- libportaudio2 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Copy requirements first for better caching
15
- COPY requirements.txt .
16
 
17
- # Install Python dependencies
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
- # Copy the application code
21
  COPY . .
22
 
23
- # Install the package
24
- RUN pip install -e .
25
-
26
- # Expose the ESPHome API port
27
- EXPOSE 6053
28
 
29
  # Set environment variables
30
  ENV PYTHONUNBUFFERED=1
31
 
32
- # Default command - can be overridden by Hugging Face Spaces
33
- CMD ["python", "-m", "reachy_mini_ha_voice", "--name", "ReachyMini"]
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies for static file serving
8
  RUN apt-get update && apt-get install -y \
9
+ python3-pip \
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Install simple HTTP server
13
+ RUN pip install --no-cache-dir fastapi uvicorn
14
 
15
+ # Copy the application files (for display only)
 
 
 
16
  COPY . .
17
 
18
+ # Expose the web port
19
+ EXPOSE 7860
 
 
 
20
 
21
  # Set environment variables
22
  ENV PYTHONUNBUFFERED=1
23
 
24
+ # Run simple web server to display the index.html
25
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Simple web server for Hugging Face Spaces display."""
2
+
3
+ from fastapi import FastAPI
4
+ from fastapi.responses import HTMLResponse, FileResponse
5
+ from fastapi.staticfiles import StaticFiles
6
+
7
+ app = FastAPI()
8
+
9
+
10
+ @app.get("/", response_class=HTMLResponse)
11
+ async def read_root():
12
+ """Serve the main page."""
13
+ with open("index.html", "r", encoding="utf-8") as f:
14
+ return f.read()
15
+
16
+
17
+ @app.get("/style.css")
18
+ async def get_style():
19
+ """Serve the CSS file."""
20
+ return FileResponse("style.css")
21
+
22
+
23
+ @app.get("/main.js")
24
+ async def get_script():
25
+ """Serve the JavaScript file."""
26
+ return FileResponse("main.js")