tts / Dockerfile
张明
Add application file
6d66075
raw
history blame contribute delete
733 Bytes
FROM python:3.10-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
build-essential \
libsndfile1 \
curl \
&& rm -rf /var/lib/apt/lists/*
# 复制 requirements 文件并安装 Python 依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制项目文件
COPY . .
# 创建模型目录(用于持久化)
RUN mkdir -p /data/models
# 暴露端口 7860
EXPOSE 7860
# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV MODEL_DIR=/data/models
# 健康检查 - 检查 API 是否响应
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# 运行应用
CMD ["python", "api.py"]