zyxciss commited on
Commit
32e9b92
·
verified ·
1 Parent(s): 702e57b

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +61 -0
Dockerfile ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
30
+ # Copy dependency files
31
+ COPY --chown=appuser:appuser pyproject.toml ./pyproject.toml
32
+
33
+ # Install dependencies
34
+ RUN --mount=type=cache,target=/root/.cache/uv \
35
+ uv venv && \
36
+ uv sync --extra cpu
37
+
38
+ # Copy project files including models
39
+ COPY --chown=appuser:appuser api ./api
40
+ COPY --chown=appuser:appuser web ./web
41
+ COPY --chown=appuser:appuser docker/scripts/ ./
42
+ RUN chmod +x ./entrypoint.sh
43
+
44
+ # Set environment variables
45
+ ENV PYTHONUNBUFFERED=1 \
46
+ PYTHONPATH=/app:/app/api \
47
+ PATH="/app/.venv/bin:$PATH" \
48
+ UV_LINK_MODE=copy \
49
+ USE_GPU=false \
50
+ PHONEMIZER_ESPEAK_PATH=/usr/bin \
51
+ PHONEMIZER_ESPEAK_DATA=/usr/share/espeak-ng-data
52
+
53
+ ENV DOWNLOAD_MODEL=true
54
+ # Download model if enabled
55
+ RUN if [ "$DOWNLOAD_MODEL" = "true" ]; then \
56
+ python download_model.py --output api/src/models/v1_0; \
57
+ fi
58
+
59
+ ENV DEVICE="cpu"
60
+ # Run FastAPI server through entrypoint.sh
61
+ CMD ["./entrypoint.sh"]