Spaces:
Running
Running
muralipala1504 commited on
Commit ·
8583d39
1
Parent(s): 0775387
feat: Dockerfile.hf single container for HuggingFace Spaces deployment
Browse files- Dockerfile.hf +53 -0
- start_hf.sh +13 -0
Dockerfile.hf
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Install system deps
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
wget curl tar python3-venv \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Copy frontend static files
|
| 11 |
+
COPY index.html app.js services.css ./
|
| 12 |
+
|
| 13 |
+
# Copy backend
|
| 14 |
+
COPY deepshell-backend/ ./deepshell-backend/
|
| 15 |
+
|
| 16 |
+
# Install DeepShell Python deps
|
| 17 |
+
RUN pip install --no-cache-dir -r deepshell-backend/requirements.txt && \
|
| 18 |
+
pip install --no-cache-dir httpx && \
|
| 19 |
+
pip install --no-cache-dir -e deepshell-backend/
|
| 20 |
+
|
| 21 |
+
# Install LibreTranslate in separate venv
|
| 22 |
+
RUN python3 -m venv /opt/venvs/libretranslate && \
|
| 23 |
+
/opt/venvs/libretranslate/bin/pip install --no-cache-dir libretranslate==1.9.5
|
| 24 |
+
|
| 25 |
+
# Pre-download LibreTranslate language models
|
| 26 |
+
RUN /opt/venvs/libretranslate/bin/libretranslate --load-only en,hi --update-files || true
|
| 27 |
+
|
| 28 |
+
# Download Piper binary
|
| 29 |
+
RUN wget -q https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_linux_x86_64.tar.gz \
|
| 30 |
+
&& tar -xzf piper_linux_x86_64.tar.gz \
|
| 31 |
+
&& rm piper_linux_x86_64.tar.gz \
|
| 32 |
+
&& mv piper /opt/piper
|
| 33 |
+
|
| 34 |
+
# Download Hindi voice model
|
| 35 |
+
RUN mkdir -p /opt/piper/voices && \
|
| 36 |
+
wget -q https://huggingface.co/rhasspy/piper-voices/resolve/main/hi/hi_IN/rohan/medium/hi_IN-rohan-medium.onnx \
|
| 37 |
+
-O /opt/piper/voices/hi_IN-rohan-medium.onnx && \
|
| 38 |
+
wget -q https://huggingface.co/rhasspy/piper-voices/resolve/main/hi/hi_IN/rohan/medium/hi_IN-rohan-medium.onnx.json \
|
| 39 |
+
-O /opt/piper/voices/hi_IN-rohan-medium.onnx.json
|
| 40 |
+
|
| 41 |
+
# Copy startup script
|
| 42 |
+
COPY start_hf.sh /app/start_hf.sh
|
| 43 |
+
|
| 44 |
+
# Env defaults
|
| 45 |
+
ENV PORT=7860
|
| 46 |
+
ENV PROVIDER=groq
|
| 47 |
+
ENV PIPER_BINARY=/opt/piper/piper
|
| 48 |
+
ENV PIPER_VOICE_DIR=/opt/piper/voices
|
| 49 |
+
ENV LIBRETRANSLATE_URL=http://localhost:5000/translate
|
| 50 |
+
|
| 51 |
+
EXPOSE 7860
|
| 52 |
+
|
| 53 |
+
CMD ["/app/start_hf.sh"]
|
start_hf.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Start LibreTranslate in background
|
| 3 |
+
source /opt/venvs/libretranslate/bin/activate
|
| 4 |
+
libretranslate --host 0.0.0.0 --port 5000 --load-only en,hi &
|
| 5 |
+
deactivate
|
| 6 |
+
|
| 7 |
+
# Warmup LibreTranslate after 10 seconds
|
| 8 |
+
sleep 10 && curl -s -X POST http://localhost:5000/translate \
|
| 9 |
+
-H "Content-Type: application/json" \
|
| 10 |
+
-d '{"q":"warmup","source":"en","target":"hi"}' > /dev/null 2>&1 &
|
| 11 |
+
|
| 12 |
+
# Start DeepShell
|
| 13 |
+
exec python -m deepshell
|