File size: 1,247 Bytes
5d30f6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874f0e4
5d30f6d
 
 
874f0e4
5d30f6d
 
874f0e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 使用 Python 3.11 作为基础镜像  
FROM python:3.11-slim  
  
# 设置工作目录  
WORKDIR /app  
  
# 设置环境变量  
ENV PYTHONUNBUFFERED=1 \  
    PYTHONDONTWRITEBYTECODE=1 \  
    PIP_NO_CACHE_DIR=1 \  
    PIP_DISABLE_PIP_VERSION_CHECK=1  
  
# 安装系统依赖  
RUN apt-get update && \  
    apt-get install -y --no-install-recommends \  
    gcc \  
    && rm -rf /var/lib/apt/lists/*  
  
# 复制项目文件  
COPY app.py .  
COPY auth_flow.py .  
COPY replicate.py .  
COPY templates/ ./templates/  
COPY frontend/ ./frontend/  
  
# 安装 Python 依赖  
# 根据项目导入的包创建依赖列表  
RUN pip install --no-cache-dir \  
    fastapi \  
    uvicorn[standard] \  
    pydantic \  
    python-dotenv \  
    requests  
  
# 创建数据目录(用于 SQLite 数据库)  
RUN mkdir -p /app/data  
  
# 复制环境变量配置文件(可选)  
COPY .env.example .env.example  
  
# 暴露端口  
EXPOSE 7860  
  
# 健康检查  
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \  
    CMD python -c "import requests; requests.get('http://localhost:7860/healthz', timeout=5)" || exit 1  
  
# 启动命令  
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]