bla commited on
Commit
276abba
·
verified ·
1 Parent(s): 6fad617

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +65 -0
Dockerfile ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Install dependencies and check espeak location
4
+ RUN apt-get update && apt-get install -y \
5
+ espeak-ng \
6
+ espeak-ng-data \
7
+ git \
8
+ libsndfile1 \
9
+ curl \
10
+ ffmpeg \
11
+ g++ \
12
+ && apt-get clean \
13
+ && rm -rf /var/lib/apt/lists/* \
14
+ && mkdir -p /usr/share/espeak-ng-data \
15
+ && ln -s /usr/lib/*/espeak-ng-data/* /usr/share/espeak-ng-data/
16
+
17
+ # Install UV using the installer script
18
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
19
+ mv /root/.local/bin/uv /usr/local/bin/ && \
20
+ mv /root/.local/bin/uvx /usr/local/bin/
21
+
22
+ # Create non-root user and set up directories and permissions
23
+ RUN useradd -m -u 1000 appuser && \
24
+ mkdir -p /app/api/src/models/v1_0 && \
25
+ chown -R appuser:appuser /app
26
+
27
+ USER appuser
28
+ WORKDIR /app
29
+ git clone https://github.com/remsky/Kokoro-FastAPI.git
30
+ cd Kokoro-FastAPI
31
+
32
+ # Copy dependency files
33
+ COPY --chown=appuser:appuser pyproject.toml ./pyproject.toml
34
+
35
+ # Install dependencies
36
+ RUN --mount=type=cache,target=/root/.cache/uv \
37
+ uv venv --python 3.10 && \
38
+ uv sync --extra cpu
39
+
40
+ # Copy project files including models
41
+ COPY --chown=appuser:appuser api ./api
42
+ COPY --chown=appuser:appuser web ./web
43
+ COPY --chown=appuser:appuser docker/scripts/ ./
44
+ RUN chmod +x ./entrypoint.sh
45
+
46
+ # Set environment variables
47
+ ENV PYTHONUNBUFFERED=1 \
48
+ PYTHONPATH=/app:/app/api \
49
+ PATH="/app/.venv/bin:$PATH" \
50
+ UV_LINK_MODE=copy \
51
+ USE_GPU=false \
52
+ PHONEMIZER_ESPEAK_PATH=/usr/bin \
53
+ PHONEMIZER_ESPEAK_DATA=/usr/share/espeak-ng-data \
54
+ ESPEAK_DATA_PATH=/usr/share/espeak-ng-data
55
+
56
+ ENV DOWNLOAD_MODEL=true
57
+ # Download model if enabled
58
+ RUN if [ "$DOWNLOAD_MODEL" = "true" ]; then \
59
+ python download_model.py --output api/src/models/v1_0; \
60
+ fi
61
+
62
+ ENV DEVICE="cpu"
63
+ # Run FastAPI server through entrypoint.sh
64
+ CMD ["/app/Kokoro-FastAPI/start-cpu.sh"]
65
+