FROM python:3.11-bookworm # 设置时区 ENV TIME_ZONE Asia/Shanghai RUN echo "${TIME_ZONE}" > /etc/timezone \ && ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime WORKDIR /app # 1. [优化] 先只拷贝依赖文件,利用 Docker 缓存 # 只要 requirements.txt 没变,这一步和 pip install 就会直接用缓存,极大加快构建速度 COPY requirements.txt /app/ # 2. 安装依赖 (使用清华源) RUN python3 -m pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ \ && python3 -m pip install --no-cache-dir gunicorn -i https://pypi.tuna.tsinghua.edu.cn/simple/ # 3. 拷贝其余项目代码 COPY . /app/ # 4. 确保脚本有执行权限 (直接处理源路径,防止移动失败) RUN chmod +x /app/deploy/dev/start.sh # 5. 指定启动入口 CMD ["/bin/bash", "/app/deploy/dev/start.sh"]