新增功能: - 精简的API服务实现(api_service_mvp.py) - 专注单一功能:去水印 - 使用LaMa模型 - API Key认证 - 完整的错误处理和日志 - 完整的部署方案 - Docker配置(APIDockerfile) - Docker Compose配置(docker-compose.mvp.yml) - Nginx反向代理配置 - 详尽的文档 - API_SERVICE_GUIDE.md - MVP到商业化完整方案 - API_SERVICE_README.md - 快速开始指南 - API_CLIENT_EXAMPLES.md - 多语言客户端示例(Python/JS/cURL/PHP/Java/Go) 架构特点: - 遵循MVP和KISS原则 - 提供从单机到Kubernetes的扩展路径 - 包含成本分析��收益模型 - 完整的监控和告警方案 🎯 适用场景: - 个人/小团队快速验证产品(月成本¥300-500) - 中小型商业化部署(月成本¥1000-3000) - 大规模生产环境(月成本¥5000+) 🔧 Generated with Claude Code
52 lines
1.2 KiB
Plaintext
52 lines
1.2 KiB
Plaintext
# 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"]
|