muralipala1504 commited on
Commit
cd47134
·
1 Parent(s): 8583d39

feat: HF Spaces deployment - single container with Piper + LibreTranslate

Browse files
Files changed (2) hide show
  1. Dockerfile +17 -6
  2. Dockerfile.hf.bak +53 -0
Dockerfile CHANGED
@@ -4,7 +4,7 @@ WORKDIR /app
4
 
5
  # Install system deps
6
  RUN apt-get update && apt-get install -y \
7
- wget curl tar \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Copy frontend static files
@@ -13,11 +13,18 @@ COPY index.html app.js services.css ./
13
  # Copy backend
14
  COPY deepshell-backend/ ./deepshell-backend/
15
 
16
- # Install 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
  # Download Piper binary
22
  RUN wget -q https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_linux_x86_64.tar.gz \
23
  && tar -xzf piper_linux_x86_64.tar.gz \
@@ -31,12 +38,16 @@ RUN mkdir -p /opt/piper/voices && \
31
  wget -q https://huggingface.co/rhasspy/piper-voices/resolve/main/hi/hi_IN/rohan/medium/hi_IN-rohan-medium.onnx.json \
32
  -O /opt/piper/voices/hi_IN-rohan-medium.onnx.json
33
 
 
 
 
34
  # Env defaults
35
- ENV PORT=8001
36
  ENV PROVIDER=groq
37
  ENV PIPER_BINARY=/opt/piper/piper
38
  ENV PIPER_VOICE_DIR=/opt/piper/voices
39
- ENV LIBRETRANSLATE_URL=http://libretranslate:5000/translate
 
 
40
 
41
- EXPOSE 8001
42
- CMD ["python", "-m", "deepshell"]
 
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
 
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 \
 
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"]
 
Dockerfile.hf.bak 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"]