feat: 添加 Dockerfile 和 docker-compose.yml 部署方案
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
# Dockerfile — md-vector-db 生产镜像
|
||||
FROM python:3.13-slim-bookworm
|
||||
|
||||
LABEL org.opencontainers.image.title="md-vector-db"
|
||||
LABEL org.opencontainers.image.description="Markdown 文档向量数据库"
|
||||
|
||||
# 系统依赖
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 先复制依赖文件以利用 Docker 层缓存
|
||||
COPY pyproject.toml uv.lock ./
|
||||
|
||||
# 安装 uv 并同步依赖(CPU 模式)
|
||||
RUN pip install --no-cache-dir uv \
|
||||
&& uv sync --frozen --no-dev \
|
||||
&& uv cache clean
|
||||
|
||||
# 复制源码和配置
|
||||
COPY config.yaml .env.example ./
|
||||
COPY src/ ./src/
|
||||
COPY scripts/ ./scripts/
|
||||
|
||||
# 创建数据目录
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8000
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/v1/health')" || exit 1
|
||||
|
||||
# 默认启动 HTTP 服务
|
||||
CMD ["uv", "run", "md-vector-db", "serve", "--port", "8000"]
|
||||
Reference in New Issue
Block a user