File size: 1,015 Bytes
66d9861
da3e04b
 
 
66d9861
 
 
 
 
 
 
 
 
 
 
 
 
da3e04b
007c288
66d9861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c8a214
da3e04b
66d9861
da3e04b
 
66d9861
007c288
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
FROM python:3.10

WORKDIR /app

# 安装基础依赖
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    ffmpeg \
    libsm6 \
    libxext6 \
    && rm -rf /var/lib/apt/lists/*

# 创建并设置模型和缓存目录
RUN mkdir -p /app/models /tmp/iopaint/cache \
    && chmod -R 777 /app/models /tmp/iopaint

# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    IOPAINT_MODEL=cv2 \
    IOPAINT_MODEL_DIR=/app/models \
    IOPAINT_DEVICE=cpu \
    TORCH_HOME=/app/models \
    HUGGINGFACE_HUB_CACHE=/app/models \
    IOPAINT_CACHE_DIR=/tmp/iopaint/cache

# 复制项目文件
COPY . .

# 安装必要的Python依赖
RUN pip install --no-cache-dir -e .

# 安装额外的依赖,确保fastapi、uvicorn和loguru已安装
RUN pip install --no-cache-dir fastapi uvicorn loguru opencv-python pillow numpy torch torchvision python-socketio

# 暴露端口
EXPOSE 7860

# 启动API服务
CMD ["python", "-m", "iopaint.api_only"]