MoiMoi-01 commited on
Commit
f43af24
·
verified ·
1 Parent(s): 9884a6a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -23
Dockerfile CHANGED
@@ -1,42 +1,54 @@
1
- # Use the official Python 3.11 slim image as the base
2
  FROM python:3.11-slim
3
 
4
- # Create non-root user
5
- RUN useradd -ms /bin/bash appuser
6
- USER appuser
7
- WORKDIR /home/appuser
8
-
9
- # Set venv path
10
  ENV VENV_PATH="/home/appuser/venv"
11
  ENV PATH="$VENV_PATH/bin:$PATH"
 
12
 
13
- # Install system dependencies
 
14
  USER root
 
 
15
  RUN apt-get update && \
16
  apt-get install -y --no-install-recommends \
17
  ffmpeg \
18
  espeak-ng \
19
  wget \
 
 
20
  python3-venv && \
21
  apt-get clean && rm -rf /var/lib/apt/lists/*
22
 
23
- # Switch back to non-root user
24
  USER appuser
 
25
 
26
- # Create and activate virtual environment
27
  RUN python3 -m venv $VENV_PATH && \
28
- $VENV_PATH/bin/pip install --no-cache-dir --upgrade pip && \
29
- $VENV_PATH/bin/pip install --no-cache-dir audiblez && \
30
- $VENV_PATH/bin/python -m spacy download xx_ent_wiki_sm
31
 
32
  # Download Kokoro model and voices
33
- RUN mkdir -p /home/appuser/.local/share/audiblez/ && \
34
- wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx -P /home/appuser/.local/share/audiblez/ && \
35
- wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json -P /home/appuser/.local/share/audiblez/
36
-
37
- # Create working and output directories
38
- WORKDIR /home/appuser/ebooks
39
- RUN mkdir -p /home/appuser/m4b
40
-
41
- # Convert and copy m4b files
42
- CMD for book in *.epub; do $VENV_PATH/bin/audiblez "$book" -v af_aoede; done && cp *.m4b /home/appuser/m4b/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
+ # System environment
 
 
 
 
 
4
  ENV VENV_PATH="/home/appuser/venv"
5
  ENV PATH="$VENV_PATH/bin:$PATH"
6
+ ENV HF_HOME="/home/appuser/.cache/huggingface"
7
 
8
+ # Create user
9
+ RUN useradd -ms /bin/bash appuser
10
  USER root
11
+
12
+ # Install system dependencies
13
  RUN apt-get update && \
14
  apt-get install -y --no-install-recommends \
15
  ffmpeg \
16
  espeak-ng \
17
  wget \
18
+ git \
19
+ curl \
20
  python3-venv && \
21
  apt-get clean && rm -rf /var/lib/apt/lists/*
22
 
23
+ # Switch to non-root user
24
  USER appuser
25
+ WORKDIR /home/appuser
26
 
27
+ # Setup virtual environment
28
  RUN python3 -m venv $VENV_PATH && \
29
+ $VENV_PATH/bin/pip install --upgrade pip && \
30
+ $VENV_PATH/bin/pip install audiblez huggingface_hub
 
31
 
32
  # Download Kokoro model and voices
33
+ RUN mkdir -p /home/appuser/.local/share/audiblez && \
34
+ wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx -P /home/appuser/.local/share/audiblez && \
35
+ wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json -P /home/appuser/.local/share/audiblez
36
+
37
+ # Create ebook and output folders
38
+ RUN mkdir -p /home/appuser/ebooks /home/appuser/m4b
39
+
40
+ # Copy EPUBs from Hugging Face Space (example with 2 test books, update as needed)
41
+ RUN wget https://huggingface.co/spaces/MoiMoi-01/AudiobookMakerAudiblezTrial/resolve/main/ebooks/MyDescendantBeggedMeToHelpHimJustAfterIBecameAGod.epub -P /home/appuser/ebooks && \
42
+ wget https://huggingface.co/spaces/MoiMoi-01/AudiobookMakerAudiblezTrial/resolve/main/ebooks/MySwordIntentCanBeInfinitelyImproved.epub -P /home/appuser/ebooks
43
+
44
+ # Final command to convert and upload m4b files
45
+ CMD for book in /home/appuser/ebooks/*.epub; do \
46
+ $VENV_PATH/bin/audiblez "$book" -v af_sky; \
47
+ done && \
48
+ cp *.m4b /home/appuser/m4b && \
49
+ echo "Uploading to Hugging Face..." && \
50
+ $VENV_PATH/bin/huggingface-cli login --token $HF_TOKEN && \
51
+ cd /home/appuser/m4b && \
52
+ for file in *.m4b; do \
53
+ huggingface-cli upload MoiMoi-01/AudiobookMakerAudiblezTrial "$file" --path_in_repo m4b/"$file"; \
54
+ done