# CCS安全扫描API Docker镜像
# 基于Python 3.11 slim镜像，最小化体积

FROM python:3.11-slim

# 元信息
LABEL maintainer="CCS Security Team"
LABEL description="MCP Configuration Security Scanner API Service"
LABEL version="1.0.0"

# 设置工作目录
WORKDIR /app

# 安装git（用于仓库克隆扫描）
RUN apt-get update && \
    apt-get install -y --no-install-recommends git && \
    rm -rf /var/lib/apt/lists/*

# 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 复制应用代码
COPY . .

# 暴露端口
EXPOSE 8000

# 健康检查
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"

# 启动命令：使用uvicorn生产模式
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2", "--log-level", "info"]
