feat: 添加统一启动脚本,支持通过环境变量配置workers数量
All checks were successful
continuous-integration/drone/push Build is passing

- 新增 start.sh 启动脚本,根据 WORKERS/RELOAD 环境变量自动配置
- 修改 Dockerfile 使用启动脚本,默认 WORKERS=4
- 更新 docker-compose.prod-multi.yml,所有租户使用环境变量配置
- 生产环境默认4个workers,提升并发处理能力

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuliang_guo
2026-02-03 14:25:34 +08:00
parent 879247c8e9
commit e110067840
3 changed files with 58 additions and 69 deletions

View File

@@ -43,9 +43,18 @@ RUN pip install --upgrade pip && \
# 复制应用代码
COPY app/ ./app/
# 复制启动脚本
COPY start.sh ./start.sh
RUN chmod +x ./start.sh
# 创建上传目录和日志目录
RUN mkdir -p uploads logs
# 默认环境变量可通过docker-compose或环境变量覆盖
ENV WORKERS=4 \
RELOAD=false \
TIMEOUT_KEEP_ALIVE=600
# 暴露端口
EXPOSE 8000
@@ -53,5 +62,5 @@ EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# 启动命令(生产模式,无热重载)
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--timeout-keep-alive", "600"]
# 使用启动脚本
CMD ["./start.sh"]