tom12112 commited on
Commit
66d9861
·
verified ·
1 Parent(s): b911230

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -30
Dockerfile CHANGED
@@ -1,39 +1,43 @@
1
- FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
- COPY . .
5
 
6
- # 安装系统依赖(OpenCV 等需要)
7
- RUN apt-get update && apt-get install -y --no-install-recommends \
8
- software-properties-common \
9
- libsm6 libxext6 ffmpeg libfontconfig1 libxrender1 libgl1-mesa-glx \
10
- curl gcc build-essential
11
-
12
- # 创建模型和缓存目录
13
- RUN mkdir -p /app/models/checkpoints && \
14
- chmod 777 /app/models/checkpoints && \
15
- mkdir -p /tmp/iopaint/models && \
16
- chmod 777 /tmp/iopaint/models && \
17
- mkdir -p /tmp/iopaint/checkpoints && \
18
- chmod 777 /tmp/iopaint/checkpoints
19
-
20
- # 安装 PyTorch CPU 版和依赖
21
- RUN pip install --no-cache-dir torch==2.0.1 torchvision==0.15.2 -f https://download.pytorch.org/whl/cpu/torch_stable.html
22
- RUN pip install -r requirements.txt
23
- RUN pip install -e .
24
 
25
  # 设置环境变量
26
- ENV IOPAINT_HOST=0.0.0.0
27
- ENV IOPAINT_PORT=7860
28
- ENV IOPAINT_MODEL=lama
29
- ENV IOPAINT_LOW_MEM=true
30
- ENV IOPAINT_DEVICE=cpu
31
- ENV PYTHONUNBUFFERED=1
32
- ENV IOPAINT_MODEL_DIR=/app/models
33
- ENV HF_ENDPOINT=https://hf-mirror.com
34
- ENV TORCH_HOME=/app/models
 
 
 
 
 
 
 
 
 
35
 
 
36
  EXPOSE 7860
37
 
38
- # 使用我们的API服务脚本
39
  CMD ["python", "-m", "iopaint.api_only"]
 
1
+ FROM python:3.10
2
 
3
  WORKDIR /app
 
4
 
5
+ # 安装基础依赖
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ git \
10
+ ffmpeg \
11
+ libsm6 \
12
+ libxext6 \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # 创建并设置模型和缓存目录
16
+ RUN mkdir -p /app/models /tmp/iopaint/cache \
17
+ && chmod -R 777 /app/models /tmp/iopaint
 
 
 
 
 
18
 
19
  # 设置环境变量
20
+ ENV PYTHONUNBUFFERED=1 \
21
+ PYTHONDONTWRITEBYTECODE=1 \
22
+ PIP_NO_CACHE_DIR=1 \
23
+ IOPAINT_MODEL=cv2 \
24
+ IOPAINT_MODEL_DIR=/app/models \
25
+ IOPAINT_DEVICE=cpu \
26
+ TORCH_HOME=/app/models \
27
+ HUGGINGFACE_HUB_CACHE=/app/models \
28
+ IOPAINT_CACHE_DIR=/tmp/iopaint/cache
29
+
30
+ # 复制项目文件
31
+ COPY . .
32
+
33
+ # 安装必要的Python依赖
34
+ RUN pip install --no-cache-dir -e .
35
+
36
+ # 安装额外的依赖,确保fastapi、uvicorn和loguru已安装
37
+ RUN pip install --no-cache-dir fastapi uvicorn loguru opencv-python pillow numpy torch torchvision
38
 
39
+ # 暴露端口
40
  EXPOSE 7860
41
 
42
+ # 启动API服务
43
  CMD ["python", "-m", "iopaint.api_only"]