Files
KCGL/inventory-backend/Dockerfile

20 lines
757 B
Docker
Raw 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
FROM python:3.8
WORKDIR /app
# 1. 复制依赖并安装
COPY requirements.txt .
# 安装依赖 + gunicorn清华镜像源 + BuildKit 缓存挂载)
# ★ 关键优化pip 下载的 wheel 会缓存在宿主 /root/.cache/pip
# 只要 requirements.txt 不变重复构建不再重新下载首次约100s之后秒级
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gunicorn
# 2. 复制后端代码
COPY . .
# 3. 启动命令
# 假设你的入口文件是 run.py实例叫 app
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "run:app"]