-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
version: '3.8' | ||
|
||
services: | ||
edge-tts-web: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: edge-tts-web | ||
restart: unless-stopped | ||
ports: | ||
- "8005:8005" | ||
volumes: | ||
- ./static/audio:/app/static/audio | ||
- ./tts.log:/app/tts.log | ||
environment: | ||
- TZ=Asia/Shanghai | ||
# 可选环境变量 | ||
- LOG_LEVEL=INFO | ||
- MAX_AUDIO_AGE=1800 # 音频文件保存时间(秒) | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8005/health"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
start_period: 10s | ||
# 使用官方 Python 基础镜像 | ||
FROM python:3.9-slim | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 设置环境变量 | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
TZ=Asia/Shanghai | ||
|
||
# 安装系统依赖 | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
curl \ | ||
libmagic1 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \ | ||
&& echo ${TZ} > /etc/timezone | ||
|
||
# 复制项目文件 | ||
COPY requirements.txt . | ||
|
||
# 安装Python依赖 | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# 复制应用程序代码 | ||
COPY . . | ||
|
||
# 创建必要的目录 | ||
RUN mkdir -p static/audio \ | ||
&& chmod -R 755 static | ||
|
||
# 暴露端口 | ||
EXPOSE 8005 | ||
|
||
# 启动命令 | ||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8005"] |