54 lines
1.4 KiB
Docker
54 lines
1.4 KiB
Docker
# 使用Python 3.12官方镜像作为基础镜像
|
||
FROM python:3.12-slim
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV PYTHONPATH=/app
|
||
ENV PYTHONUNBUFFERED=1
|
||
|
||
# 安装系统依赖
|
||
RUN apt-get update && apt-get install -y \
|
||
curl \
|
||
wget \
|
||
gnupg2 \
|
||
ca-certificates \
|
||
libpq-dev \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 安装Node.js (支持npx命令)
|
||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||
apt-get install -y nodejs
|
||
|
||
# 安装uv (Python包管理器)
|
||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||
|
||
# 设置环境变量以便访问uv
|
||
ENV PATH="/root/.cargo/bin:$PATH"
|
||
|
||
# 复制requirements文件并安装Python依赖
|
||
COPY requirements.txt .
|
||
RUN pip install --no-cache-dir -r requirements.txt
|
||
|
||
# 复制应用代码
|
||
COPY . .
|
||
|
||
# 创建必要的目录
|
||
RUN mkdir -p /app/projects
|
||
RUN mkdir -p /app/public
|
||
RUN mkdir -p /app/models
|
||
|
||
# 下载sentence-transformers模型到models目录
|
||
RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('TaylorAI/gte-tiny'); model.save('/app/models/gte-tiny')"
|
||
|
||
# 暴露端口
|
||
EXPOSE 8001
|
||
|
||
# 健康检查
|
||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
||
CMD curl -f http://localhost:8001/api/health || exit 1
|
||
|
||
# 启动命令 - profile通过环境变量PROFILE配置,默认为balanced
|
||
CMD ["sh", "-c", "python3 start_unified.py --profile ${PROFILE:-balanced}"]
|