DSLZLERS commited on
Commit
5d30f6d
·
unverified ·
1 Parent(s): a393763

Create Dockerfile

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