FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ KNOWLEDGE_SEARCH_MODE=lite WORKDIR /app # 健康检查依赖 curl;不安装 torch/sentence-transformers,保持运行镜像轻量 RUN apt-get update \ && apt-get install -y --no-install-recommends curl ca-certificates \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt \ --index-url https://mirrors.aliyun.com/pypi/simple/ \ --trusted-host mirrors.aliyun.com # 应用 COPY config.py . COPY db/ db/ COPY handlers/ handlers/ COPY services/ services/ COPY rules/ rules/ COPY web/ web/ COPY knowledge/ knowledge/ COPY main.py . HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ CMD curl -fsS http://127.0.0.1:${WEB_PORT:-8766}/health || exit 1 CMD ["python", "main.py"]