tom12112 commited on
Commit
007c288
·
verified ·
1 Parent(s): 4161fe6

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -26
Dockerfile CHANGED
@@ -1,47 +1,36 @@
1
  FROM python:3.10-slim
2
 
3
  WORKDIR /app
 
4
 
5
- # 安装系统依赖
6
- RUN apt-get update && apt-get install -y \
7
- build-essential \
8
- libgl1-mesa-glx \
9
- libglib2.0-0 \
10
- wget \
11
- git \
12
- && rm -rf /var/lib/apt/lists/*
13
 
14
- # 创建模型和缓存目录并设置权限
15
  RUN mkdir -p /app/models && \
16
  chmod 777 /app/models && \
17
- mkdir -p /app/.cache/huggingface/hub && \
18
- chmod 777 /app/.cache/huggingface/hub && \
19
  mkdir -p /tmp/iopaint/models && \
20
  chmod 777 /tmp/iopaint/models
21
 
22
- # 复制项目文件
23
- COPY . /app/
 
 
24
 
25
- # 确保入口脚本有执行权限
26
- RUN chmod +x /app/entrypoint.sh
27
-
28
- # 安装Python依赖和项目
29
- RUN pip install --no-cache-dir -r requirements.txt
30
- RUN pip install --no-cache-dir -e .
31
-
32
- # 环境变量设置
33
  ENV IOPAINT_HOST=0.0.0.0
34
  ENV IOPAINT_PORT=7860
35
  ENV IOPAINT_MODEL=lama
36
  ENV IOPAINT_LOW_MEM=true
37
  ENV IOPAINT_DEVICE=cpu
38
  ENV PYTHONUNBUFFERED=1
39
- ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/hub
40
- ENV HF_HOME=/app/.cache/huggingface
41
  ENV IOPAINT_MODEL_DIR=/app/models
 
42
 
43
- # 暴露端口
44
  EXPOSE 7860
45
 
46
- # 使用入口脚本启动
47
- CMD ["/app/entrypoint.sh"]
 
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 && \
14
  chmod 777 /app/models && \
 
 
15
  mkdir -p /tmp/iopaint/models && \
16
  chmod 777 /tmp/iopaint/models
17
 
18
+ # 安装 PyTorch CPU 版和依赖
19
+ RUN pip install --no-cache-dir torch==2.0.1 torchvision==0.15.2 -f https://download.pytorch.org/whl/cpu/torch_stable.html
20
+ RUN pip install -r requirements.txt
21
+ RUN pip install -e .
22
 
23
+ # 设置环境变量
 
 
 
 
 
 
 
24
  ENV IOPAINT_HOST=0.0.0.0
25
  ENV IOPAINT_PORT=7860
26
  ENV IOPAINT_MODEL=lama
27
  ENV IOPAINT_LOW_MEM=true
28
  ENV IOPAINT_DEVICE=cpu
29
  ENV PYTHONUNBUFFERED=1
 
 
30
  ENV IOPAINT_MODEL_DIR=/app/models
31
+ ENV HF_ENDPOINT=https://hf-mirror.com
32
 
 
33
  EXPOSE 7860
34
 
35
+ # 使用我们的API服务脚本
36
+ CMD ["python", "-m", "iopaint.api_only"]