leonsimon23 commited on
Commit
def98cb
·
verified ·
1 Parent(s): 0031a75

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -0
Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用Python 3.9官方镜像作为基础镜像
2
+ FROM python:3.9-slim
3
+
4
+ # 设置工作目录
5
+ WORKDIR /app
6
+
7
+ # 安装系统依赖
8
+ RUN apt-get update && apt-get install -y \
9
+ gcc \
10
+ g++ \
11
+ libjpeg-dev \
12
+ libpng-dev \
13
+ libfreetype6-dev \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # 复制 requirements.txt 文件到容器中
17
+ COPY requirements.txt .
18
+
19
+ # 安装 Python 依赖
20
+ RUN pip install --no-cache-dir -r requirements.txt
21
+
22
+ # 复制你的应用代码到容器中
23
+ COPY . .
24
+
25
+ # 暴露 Flask 应用运行的端口,这里使用 Hugging Face 默认的 7860
26
+ EXPOSE 7860
27
+
28
+ # 启动 Gunicorn 服务器来运行 Flask 应用
29
+ # Gunicorn 比 Flask 自带的开发服务器更适合生产环境
30
+ # 绑定到 0.0.0.0 确保它能被外部访问
31
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "4", "app:app"]