Files
2026-08-11 22:07:55 +08:00

24 lines
941 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.
FROM python:3.11-slim
# System dependencies (mirrors.aliyun.com for CN networks)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
# 复制项目代码(含 .git,供 compose 的 app_code 卷内 git pull 更新工作流使用)
COPY . /app
WORKDIR /app
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
# Gunicorn:2 个 worker 对应 2 逻辑核心(1 物理核心),线程模式;
# 2G 内存/2 CPU 限制由 docker-compose.yml 的 deploy.resources 配置。
# 后台调度器通过 PostgreSQL advisory lock 保证只在其中一个 worker 内运行。
CMD gunicorn --workers ${GUNICORN_WORKERS:-2} --threads ${GUNICORN_THREADS:-8} \
--bind 0.0.0.0:5000 --timeout 120 \
--access-logfile - --error-logfile - start:app