Spaces:
Sleeping
Sleeping
| # 使用官方 Python 3.11 slim 镜像 | |
| FROM python:3.11-slim | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # 复制 requirements 文件 | |
| COPY requirements.txt . | |
| # 安装 Python 依赖 | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 复制应用代码 | |
| COPY app.py . | |
| # 暴露端口 (Hugging Face Spaces 默认使用 7860) | |
| EXPOSE 7860 | |
| # 设置环境变量,确保 Python 输出不会被缓冲 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PORT=7860 | |
| # 启动 FastAPI 应用 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |