2026-01-19 11:14:41 +08:00

21 lines
622 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用官方 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"]