- 런타임 이미지에서 컴파일러 툴체인(build-essential/git) 제외 - triton 제거(추론엔 불필요, torch.compile 전용) - 미사용 gruut 언어팩(es/de/fr) 제거 - 슬림화 후 한/영 모델 로드 검증 단계 추가
70 lines
2.6 KiB
Docker
70 lines
2.6 KiB
Docker
# ---------- 빌더 단계 ----------
|
|
FROM python:3.11-slim AS builder
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
HF_HOME=/models \
|
|
NLTK_DATA=/models/nltk_data \
|
|
HF_HUB_DISABLE_TELEMETRY=1
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential git ffmpeg libsndfile1 curl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
RUN mkdir -p /models/nltk_data
|
|
|
|
# Blackwell(sm_120) 지원 torch cu128 휠
|
|
RUN pip install torch==2.11.0 torchaudio==2.11.0 \
|
|
--index-url https://download.pytorch.org/whl/cu128
|
|
|
|
COPY constraints.txt requirements.txt ./
|
|
RUN pip install -c constraints.txt -r requirements.txt
|
|
|
|
# MeloTTS(순수 파이썬) 벤더링
|
|
COPY vendor/melo /usr/local/lib/python3.11/site-packages/melo
|
|
|
|
# 한국어/영어 모델 사전 다운로드
|
|
COPY warmup.py ./
|
|
RUN python warmup.py
|
|
|
|
# 슬림화: 추론에 불필요한 패키지 제거
|
|
# - triton: torch.compile 전용(우리는 eager 추론이라 불필요)
|
|
# - gruut 미사용 언어(es/de/fr): 영어만 사용
|
|
RUN pip uninstall -y triton 2>/dev/null || true \
|
|
&& rm -rf /usr/local/lib/python3.11/site-packages/gruut_lang_es \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_de \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_fr \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_es-*.dist-info \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_de-*.dist-info \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_fr-*.dist-info \
|
|
&& find /usr/local/lib/python3.11/site-packages -name "__pycache__" -type d -prune -exec rm -rf {} + 2>/dev/null || true
|
|
|
|
# 슬림화 후에도 한/영 모델이 정상 로드되는지 검증
|
|
RUN python -c "from melo.api import TTS; TTS('KR', device='cpu'); TTS('EN', device='cpu'); print('slim import ok')"
|
|
|
|
# ---------- 런타임 단계 ----------
|
|
FROM python:3.11-slim AS runtime
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
HF_HOME=/models \
|
|
NLTK_DATA=/models/nltk_data \
|
|
HF_HUB_DISABLE_TELEMETRY=1
|
|
|
|
# 런타임 필수 라이브러리만 (컴파일러 툴체인 제외)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ffmpeg libsndfile1 libgomp1 ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
COPY --from=builder /models /models
|
|
|
|
COPY app ./app
|
|
COPY frontend ./frontend
|
|
|
|
# 기본 MeloTTS 단일 엔진 (자동 언어 감지: 한/영 혼합)
|
|
EXPOSE 8788
|
|
CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "8788"]
|