hins111 commited on
Commit
eb86367
·
verified ·
1 Parent(s): 9d831fa

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -0
Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===================================================================
2
+ # Dockerfile
3
+ # ===================================================================
4
+
5
+ # 使用官方的 Python 3.9 轻量级镜像
6
+ FROM python:3.9-slim
7
+
8
+ # 设置工作目录
9
+ WORKDIR /app
10
+
11
+ # 将项目所有文件复制到工作目录
12
+ # 我们会上传 main.py 和 requirements.txt
13
+ COPY . .
14
+
15
+ # 从 requirements.txt 安装所有 Python 依赖
16
+ # --no-cache-dir 选项可以减小镜像体积
17
+ RUN pip install --no-cache-dir --upgrade pip && \
18
+ pip install --no-cache-dir -r requirements.txt
19
+
20
+ # 暴露 FastAPI 默认运行的 8000 端口
21
+ EXPOSE 8000
22
+
23
+ # 容器启动时运行的命令
24
+ # 启动 uvicorn 服务器,监听所有网络接口的 8000 端口
25
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]