forked from zaigie/FunSpeech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.optimized
More file actions
71 lines (53 loc) · 2.06 KB
/
Copy pathDockerfile.optimized
File metadata and controls
71 lines (53 loc) · 2.06 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
63
64
65
66
67
68
69
70
# Build stage: Install dependencies and build tools
FROM python:3.10-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libsox-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Upgrade pip and install build tools
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir build hatchling
# Pre-install PyTorch CPU wheels to avoid pulling CUDA runtimes
RUN pip install --no-cache-dir \
--index-url https://download.pytorch.org/whl/cpu \
torch==2.3.1 \
torchaudio==2.3.1
# Copy pyproject.toml and README.md for better layer caching
COPY pyproject.toml README.md ./
# Install main project dependencies from pyproject.toml
# Note: pip install . will install dependencies defined in pyproject.toml (including funasr)
RUN pip install --no-cache-dir .
# Runtime stage: Minimal runtime image
FROM python:3.10-slim AS runtime
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HF_HUB_DISABLE_SYMLINKS_WARNING=1 \
HF_HUB_DISABLE_PROGRESS_BARS=1 \
PYTHONPATH=/app
# Install only runtime system packages (no build tools)
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
sox \
libsndfile1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy installed Python packages from builder
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY . .
# Create runtime directories with proper permissions
RUN mkdir -p /app/temp /app/data /app/voices /app/logs \
&& chmod +x start.py
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=5)" || exit 1
CMD ["python", "start.py"]