-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.cpu
More file actions
61 lines (47 loc) · 1.57 KB
/
Copy pathDockerfile.cpu
File metadata and controls
61 lines (47 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
HF_HOME=/app/hf_cache
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
sox \
libsox-dev \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install PyTorch CPU-only version first, then other dependencies
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir -r requirements.txt
# Pre-download model (accepts shorthand like "0.6B" or full path)
ARG MODEL_NAME=0.6B
ENV MODEL_NAME=${MODEL_NAME}
# Copy config first to use MODEL_MAP for resolving shorthand
COPY app/config.py .
# Create cache directory and download model during build
RUN mkdir -p /app/hf_cache && \
python -c "from config import get_model_name; from huggingface_hub import snapshot_download; snapshot_download(get_model_name())"
# Copy application code
COPY app/ .
# Create directories
RUN mkdir -p /app/voices /app/cache
# Set default environment variables
ENV HOST=0.0.0.0 \
PORT=8880 \
DEVICE=cpu \
VOICES_DIR=/app/voices \
CACHE_DIR=/app/cache
# Expose port
EXPOSE 8880
# Health check (longer timeout for CPU)
HEALTHCHECK --interval=30s --timeout=60s --start-period=180s --retries=3 \
CMD curl -f http://localhost:8880/health || exit 1
# Run server
CMD ["python", "server.py"]