# 使用 Python 3.10 精简版镜像 FROM python:3.10-slim # 设置工作目录 WORKDIR /app # 复制项目的 requirements.txt COPY requirements.txt /app/ # 配置 pip 使用阿里云镜像并安装依赖 RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \ && pip install --no-cache-dir -r requirements.txt # 复制整个后端项目到容器 COPY . /app/ # 设置环境变量 ENV PYTHONUNBUFFERED=1 RUN mkdir tasks \ && chmod 777 tasks # 设置默认的命令,启动 Uvicorn 服务 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]