deploy docker

This commit is contained in:
2025-04-10 09:45:41 +00:00
parent 1955f05876
commit b3fc313a15
46 changed files with 1024 additions and 169 deletions
+2 -52
View File
@@ -21,58 +21,8 @@ REDIS_SESSION_DB_ZH=48
REDIS_SESSION_DB_EN=49
REDIS_SESSION_DB_KO=50
# GPT-SoVITS 配置
GPT_MODEL_PATH=GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt
SOVITS_MODEL_PATH=GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth
REF_AUDIO_PATH=sample/woman.wav
REF_TEXT_PATH=sample/woman.txt
REF_LANGUAGE=中文
TARGET_LANGUAGE=多语种混合
OUTPUT_PATH=/obscura/task/audio_files
# VOICE_CONFIGS
GIRL_REF_AUDIO=sample/gril.wav
GIRL_REF_TEXT=sample/gril.txt
WOMAN_REF_AUDIO=sample/woman.wav
WOMAN_REF_TEXT=sample/woman.txt
MAN_REF_AUDIO=sample/man.wav
MAN_REF_TEXT=sample/man.txt
LEIJUN_REF_AUDIO=sample/leijun.wav
LEIJUN_REF_TEXT=sample/leijun.txt
DUFU_REF_AUDIO=sample/dufu.wav
DUFU_REF_TEXT=sample/dufu.txt
HEJIONG_REF_AUDIO=sample/hejiong.wav
HEJIONG_REF_TEXT=sample/hejiong.txt
MAHUATENG_REF_AUDIO=sample/mahuateng.wav
MAHUATENG_REF_TEXT=sample/mahuateng.txt
LIDAN_REF_AUDIO=sample/lidan.wav
LIDAN_REF_TEXT=sample/lidan.txt
YUHUA_REF_AUDIO=sample/yuhua.wav
YUHUA_REF_TEXT=sample/yuhua.txt
LIUZHENYUN_REF_AUDIO=sample/liuzhenyun.wav
LIUZHENYUN_REF_TEXT=sample/liuzhenyun.txt
DABING_REF_AUDIO=sample/dabing.wav
DABING_REF_TEXT=sample/dabing.txt
LUOXIANG_REF_AUDIO=sample/luoxiang.wav
LUOXIANG_REF_TEXT=sample/luoxiang.txt
XUZHIYUAN_REF_AUDIO=sample/xuzhiyuan.wav
XUZHIYUAN_REF_TEXT=sample/xuzhiyuan.txt
UPLOAD_DIR = "/obscura/task/upload"
RESULT_DIR = "/obscura/task/result"
REDIS_GIRL_DB = 51
+70
View File
@@ -0,0 +1,70 @@
# 构建阶段
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 配置apt源为清华源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
build-essential \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install -y python3.11 python3.11-dev python3.11-distutils \
&& curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3.11 get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 设置Python 3.11为默认版本
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11
WORKDIR /producer_chat
# 配置pip源为清华源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 安装依赖
COPY requirements.txt .
RUN python3 -m pip install --no-cache-dir -r requirements.txt
# 最终阶段
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 配置apt源为清华源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
ffmpeg \
libgl1-mesa-glx \
python3.11 \
python3.11-distutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 设置Python 3.11为默认版本
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11
WORKDIR /producer_chat
# 从构建阶段复制Python包
COPY --from=builder /usr/local/lib/python3.11/dist-packages /usr/local/lib/python3.11/dist-packages
# 复制应用代码
COPY . .
# 创建必要的目录
RUN mkdir -p /obscura/task/upload /obscura/task/result /obscura/task/audio_files
CMD ["python3", "producer_chat.py"]
+1 -4
View File
@@ -10,7 +10,6 @@ import json
import uuid
from datetime import datetime, timezone
from dotenv import load_dotenv
import tempfile
import hashlib
from pydantic import BaseModel, Field
@@ -65,8 +64,7 @@ KAFKA_TTS_TOPIC = os.getenv('KAFKA_TTS_TOPIC')
KAFKA_ASR_TOPIC = os.getenv('KAFKA_ASR_TOPIC')
KAFKA_CHAT_TOPIC = os.getenv('KAFKA_CHAT_TOPIC')
OUTPUT_PATH= os.getenv('OUTPUT_PATH')
UPLOAD_DIR = os.getenv('UPLOAD_DIR')
# 初始化 Kafka Producer
producer = KafkaProducer(
bootstrap_servers=[KAFKA_BROKER],
@@ -261,7 +259,6 @@ async def tts_request(request: TTSRequest, api_key_info: dict = Depends(verify_a
async def asr_request(audio: UploadFile = File(...), api_key_info: dict = Depends(verify_api_key)):
task_id = str(uuid.uuid4())
UPLOAD_DIR = "/obscura/task/audio_upload"
os.makedirs(UPLOAD_DIR, exist_ok=True)
file_path = os.path.join(UPLOAD_DIR, f"{task_id}.wav")
Executable → Regular
+17 -7
View File
@@ -1,7 +1,17 @@
fastapi
uvicorn
pydantic
kafka-python
redis
python-dotenv
python-multipart
fastapi>=0.115.0
uvicorn>=0.34.0
pydantic>=2.11.0
kafka-python>=2.1.0
redis>=5.2.0
python-dotenv>=1.1.0
bcrypt>=4.3.0
python-jose>=3.4.0
passlib>=1.7.0
cryptography>=44.0.0
requests>=2.32.0
numpy>=2.2.0
pillow>=11.1.0
decord>=0.6.0
python-multipart>=0.0.20
typing_extensions>=4.13.0
async_timeout>=4.0.0