21 lines
622 B
Docker
Raw Permalink Normal View History

2026-01-19 11:14:41 +08:00
# 使用官方 Python 3.8.2 slim 镜像(精简版)
FROM python:3.8.2-slim
# 设置工作目录
WORKDIR /app
# 安装依赖前先复制 requirements利用 Docker 缓存)
COPY requirements.txt .
# 升级 pip 并安装依赖(使用国内源加速,可选)
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 复制应用代码
COPY . .
# 暴露端口
EXPOSE 5000
# 启动命令(使用 gunicorn 提升生产性能)
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--timeout", "60", "main:app"]