# IOPaint API Service - MVP Dockerfile # 专门用于去水印API服务的精简镜像 FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 # 安装系统依赖 RUN apt-get update && apt-get install -y --no-install-recommends \ python3.11 \ python3-pip \ libsm6 \ libxext6 \ libxrender1 \ libgl1-mesa-glx \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # 升级pip RUN pip3 install --no-cache-dir --upgrade pip # 安装PyTorch(CUDA 12.1) RUN pip3 install --no-cache-dir \ torch torchvision --index-url https://download.pytorch.org/whl/cu121 WORKDIR /app # 复制核心文件(只复制必要的) COPY requirements.txt setup.py ./ COPY iopaint ./iopaint # 安装Python依赖 RUN pip3 install --no-cache-dir -r requirements.txt && \ pip3 install --no-cache-dir -e . # 复制API服务文件 COPY api_service_mvp.py ./ # 创建日志目录 RUN mkdir -p /app/logs # 暴露端口 EXPOSE 8080 # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD python3 -c "import requests; requests.get('http://localhost:8080/api/v1/health').raise_for_status()" || exit 1 # 启动命令 CMD ["python3", "api_service_mvp.py"]