MoiMoi-01 commited on
Commit
0dfbf11
·
verified ·
1 Parent(s): a361896

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -17
Dockerfile CHANGED
@@ -1,35 +1,42 @@
1
  # Use the official Python 3.11 slim image as the base
2
  FROM python:3.11-slim
3
 
4
- # Set environment variables
5
- ENV VENV_PATH="/venv"
 
 
 
 
 
6
  ENV PATH="$VENV_PATH/bin:$PATH"
7
 
8
  # Install system dependencies
 
9
  RUN apt-get update && \
10
  apt-get install -y --no-install-recommends \
11
  ffmpeg \
12
  espeak-ng \
13
  wget \
14
  python3-venv && \
15
- apt-get clean && \
16
- rm -rf /var/lib/apt/lists/*
 
 
17
 
18
- # Create and activate virtual environment, then install audiblez
19
- RUN python -m venv $VENV_PATH && \
20
  $VENV_PATH/bin/pip install --no-cache-dir --upgrade pip && \
21
- $VENV_PATH/bin/pip install --no-cache-dir audiblez
 
22
 
23
  # Download Kokoro model and voices
24
- RUN mkdir -p /root/.local/share/audiblez/ && \
25
- wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx -P /root/.local/share/audiblez/ && \
26
- wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json -P /root/.local/share/audiblez/
27
-
28
- # Set the working directory to /ebooks
29
- WORKDIR /ebooks
30
 
31
- # Create the /m4b directory
32
- RUN mkdir -p /m4b
 
33
 
34
- # Copy all .m4b output to /m4b after conversion using audiblez from venv
35
- CMD for book in *.epub; do $VENV_PATH/bin/audiblez "$book" -v af_aoede; done && cp *.m4b /m4b/
 
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/