forked from cmcouto-silva/nl2sql-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 940 Bytes
/
Dockerfile
File metadata and controls
40 lines (31 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 使用 Python 3.12 作为基础镜像
FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
gcc \
g++ \
postgresql-client \
curl \
&& rm -rf /var/lib/apt/lists/*
# 安装 uv
RUN pip install --no-cache-dir uv
# 复制项目文件
COPY pyproject.toml uv.lock README.md ./
COPY nl2sql ./nl2sql
COPY configs ./configs
COPY knowledge ./knowledge
# 使用 uv 安装依赖(不安装开发依赖)
RUN uv sync --frozen --no-dev
# 暴露端口
EXPOSE 8000
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV PATH="/app/.venv/bin:$PATH"
# 健康检查
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# 启动应用(使用 uv 运行,它会自动使用 .venv)
CMD ["uv", "run", "uvicorn", "nl2sql.api.main:app", "--host", "0.0.0.0", "--port", "8000"]