-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (47 loc) · 1.61 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (47 loc) · 1.61 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
62
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
# 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 Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.5.4/flash_attn-2.8.3+cu124torch2.5-cp311-cp311-linux_x86_64.whl
# 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=cuda:0 \
VOICES_DIR=/app/voices \
CACHE_DIR=/app/cache
# Expose port
EXPOSE 8880
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \
CMD curl -f http://localhost:8880/health || exit 1
# Run server
CMD ["python", "server.py"]