This commit is contained in:
ZhuJW
2026-04-22 13:35:40 +08:00
commit 26a7fdf6c0
40 changed files with 11602 additions and 0 deletions

43
Dockerfile Normal file
View File

@@ -0,0 +1,43 @@
# 多阶段构建:减小最终镜像体积
FROM python:3.11
# 设置工作目录
WORKDIR /app
# 复制依赖文件
COPY requirements.txt .
# 安装运行时依赖
RUN pip install -r requirements.txt -i https://mirrors.cloud.tencent.com/pypi/simple/
# 复制应用代码
COPY . .
# 配置应用目录结构
RUN mkdir -p /app/__pycache__ /app/logs
# 配置时区
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
# 端口配置(默认生产 5222可用于本地测试 5228
ARG APP_PORT=5222
ENV APP_PORT=$APP_PORT
# 暴露Gunicorn监听的端口对外提供服务
EXPOSE ${APP_PORT}
# 环境变量配置
# ENV FLASK_APP="app:app" \
# FLASK_ENV="production" \
ENV PYTHONUNBUFFERED=1 \
PATH="/venv/bin:$PATH"
# Gunicorn启动命令核心配置
CMD ["sh", "-c", "gunicorn \
--bind 0.0.0.0:${APP_PORT} \
--workers 14 \
--timeout 60 \
--keep-alive 5 \
--access-logfile - \
--error-logfile - \
run:app"]