Files
2026-09-15 21:32:20 +08:00

12 lines
627 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.12-slim
WORKDIR /app
# 先只拷 requirements 加装依赖层,业务代码改动不触发重装
COPY requirements.txt .
# 大陆网络备用源:清华 pypi 镜像
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY . .
EXPOSE 8000
# 启动即 migrate(单副本场景简单可靠),随后 gunicorn 3 worker
# --forwarded-allow-ips=*:信任前置 Nginx 传入的 X-Forwarded-For(DRF NUM_PROXIES=1 取末段还原客户端 IP)
CMD ["sh", "-c", "python manage.py migrate && gunicorn config.wsgi:application -b 0.0.0.0:8000 -w 3 --forwarded-allow-ips=*"]