# 使用Python官方镜像作为基础镜像 FROM python:3.10-slim # 设置工作目录 WORKDIR /app # 设置环境变量 ENV API_TOKEN=sk-114514 # 复制依赖文件 COPY requirements.txt . # 设置清华镜像源并安装依赖 RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \ && pip install --no-cache-dir -r requirements.txt # 复制应用代码 COPY . . # 暴露应用端口 EXPOSE 8080 # 启动应用 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]