Spaces:
Sleeping
Sleeping
| # 使用 Python 3.11 作为基础镜像 | |
| FROM python:3.11-slim | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # 设置环境变量 | |
| ENV PYTHONDONTWRITEBYTECODE 1 | |
| ENV PYTHONUNBUFFERED 1 | |
| # 安装系统依赖 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 复制 requirements.txt 并安装 Python 依赖 | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 复制项目代码 | |
| COPY . . | |
| # 创建实例目录用于数据库持久化 | |
| RUN mkdir -p instance static | |
| RUN chmod 777 instance static | |
| # 暴露端口 | |
| EXPOSE 7860 | |
| # 启动命令 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |