feat:新增部署脚本

This commit is contained in:
2026-10-13 02:41:13 -07:00
parent 5b6d16c559
commit 828704e3e8
3 changed files with 187 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
FROM python:3.11-slim-bookworm AS builder
COPY --from=ghcr.io/astral-sh/uv:0.12.17 /uv /usr/local/bin/uv
WORKDIR /app
ENV UV_PYTHON_DOWNLOADS=never
COPY pyproject.toml uv.lock ./
RUN uv sync --locked --no-dev --no-install-project
FROM python:3.11-slim-bookworm
# PyArrow、DuckDB 的 Linux wheels 需要 C++ 运行库
RUN apt-get update \
&& apt-get install -y --no-install-recommends libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH" \
UVICORN_HOST=0.0.0.0 \
UVICORN_PORT=8000
WORKDIR /app
COPY --from=builder /app/.venv ./.venv
COPY app ./app
COPY mcp_servers ./mcp_servers
COPY mcp_servers.json ./
COPY skills ./skills
COPY scripts/seed_materials.py ./scripts/seed_materials.py
EXPOSE 8000
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ['UVICORN_PORT'] + '/api/files/limits', timeout=3).close()" || exit 1
CMD ["python", "-m", "uvicorn", "app.main:app", "--workers", "1"]