LucasLooTan Claude Opus 4.7 (1M context) commited on
Commit
961668b
·
1 Parent(s): c956715

fix: switch to Docker SDK so Python + launch are fully under our control

Browse files

Gradio 4.44.1 + HF default Python 3.13 hit ModuleNotFoundError(pyaudioop)
because pyaudioop was removed from stdlib in 3.13 — and pydub (gradio's
audio dep) hardcodes that import. Pinning python_version to 3.10/3.11
exposed a separate gradio runtime issue ('localhost not accessible').

Switching to Docker SDK (python:3.11-slim) gives us:
- working pydub / gradio audio
- mediapipe wheel installs cleanly (no 3.13 wheel exists yet)
- explicit GRADIO_SERVER_NAME=0.0.0.0 and port 7860
- predictable layered build (cached pip install of requirements.txt)

app.py keeps its env-driven server_name/port for parity with the
Dockerfile defaults.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (3) hide show
  1. Dockerfile +33 -0
  2. README.md +2 -3
  3. app.py +7 -5
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HF Space Docker SDK runtime — pin python 3.11 (mediapipe + gradio happy)
2
+ FROM python:3.11-slim
3
+
4
+ # System deps for OpenCV / gradio video / pillow
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ git \
7
+ libgl1 \
8
+ libglib2.0-0 \
9
+ libsm6 \
10
+ libxext6 \
11
+ libxrender1 \
12
+ ffmpeg \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ WORKDIR /app
16
+
17
+ # HF Spaces Docker SDK convention: app expects user "user" with UID 1000
18
+ RUN useradd -m -u 1000 user
19
+ USER user
20
+ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH HF_HOME=/home/user/.cache/huggingface
21
+
22
+ COPY --chown=user requirements.txt /app/requirements.txt
23
+ RUN pip install --no-cache-dir --user -r /app/requirements.txt
24
+
25
+ COPY --chown=user . /app
26
+
27
+ # HF Spaces Docker convention: app must listen on 0.0.0.0:7860
28
+ ENV GRADIO_SERVER_NAME=0.0.0.0 \
29
+ GRADIO_SERVER_PORT=7860 \
30
+ GRADIO_ANALYTICS_ENABLED=False
31
+ EXPOSE 7860
32
+
33
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -3,9 +3,8 @@ title: SignBridge
3
  emoji: 🤟
4
  colorFrom: indigo
5
  colorTo: pink
6
- sdk: gradio
7
- sdk_version: 4.44.1
8
- app_file: app.py
9
  pinned: false
10
  thumbnail: assets/cover.png
11
  license: mit
 
3
  emoji: 🤟
4
  colorFrom: indigo
5
  colorTo: pink
6
+ sdk: docker
7
+ app_port: 7860
 
8
  pinned: false
9
  thumbnail: assets/cover.png
10
  license: mit
app.py CHANGED
@@ -17,11 +17,13 @@ from signbridge.space import build_demo
17
  def main() -> None:
18
  load_dotenv()
19
  demo = build_demo()
20
- # On HF Spaces the gradio runtime sets GRADIO_SERVER_NAME / SERVER_PORT
21
- # in env and auto-launches; passing custom server_name/port can collide
22
- # with the pre-startup localhost check. Calling .launch() with no args
23
- # is the documented "just works" pattern for HF Spaces.
24
- demo.queue().launch()
 
 
25
 
26
 
27
  if __name__ == "__main__":
 
17
  def main() -> None:
18
  load_dotenv()
19
  demo = build_demo()
20
+ # Docker-SDK Space: we own the runtime, bind explicitly. Env vars from
21
+ # the Dockerfile set GRADIO_SERVER_NAME=0.0.0.0 / PORT=7860 already; the
22
+ # explicit args here are belt-and-suspenders.
23
+ demo.queue().launch(
24
+ server_name=os.getenv("GRADIO_SERVER_NAME", "0.0.0.0"),
25
+ server_port=int(os.getenv("GRADIO_SERVER_PORT", "7860")),
26
+ )
27
 
28
 
29
  if __name__ == "__main__":