forked from ZeroPointSix/outlookEmailPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (28 loc) · 1.11 KB
/
Copy pathDockerfile
File metadata and controls
37 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 使用 Python 3.11 作为基础镜像
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
GUNICORN_WORKERS=1 \
GUNICORN_THREADS=8 \
GUNICORN_TIMEOUT=120
# 复制依赖文件
COPY requirements.txt .
# 安装依赖(pip 走国内镜像加速)
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install gunicorn -i https://pypi.tuna.tsinghua.edu.cn/simple
# 复制应用代码
COPY . .
# 创建数据目录
RUN mkdir -p /app/data && chmod +x /app/scripts/start-gunicorn.sh
# 暴露端口
EXPOSE 5000
# 健康检查
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s CMD ["python","-c","import urllib.request as u; u.urlopen('http://localhost:5000/healthz', timeout=4).read()"]
# 启动应用:默认单 worker + 多线程,避免同步长轮询阻塞整站
# 注意:禁用 --preload,避免在 master 进程中启动后台调度线程
CMD ["scripts/start-gunicorn.sh"]