12 lines
627 B
Docker
12 lines
627 B
Docker
|
|
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=*"]
|