qwen_agent/Dockerfile.modelscope
2026-03-17 14:27:16 +08:00

65 lines
1.9 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用Python 3.12官方镜像作为基础镜像
FROM docker.1ms.run/python:3.12-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV PLAYWRIGHT_BROWSERS_PATH=/usr
ENV CHROME_PATH=/usr/bin/chromium
# 安装系统依赖
RUN sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y \
curl \
wget \
gnupg2 \
ca-certificates \
libpq-dev \
chromium \
&& 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 -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
# 安装 Playwright (使用系统 chromium无需额外下载)
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ playwright
RUN npm install -g playwright
# 安装modelscope
#RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ modelscope
# 创建必要的目录
RUN mkdir -p /app/projects
RUN mkdir -p /app/public
RUN mkdir -p /app/models
# 从modelscope下载sentence-transformers模型到models目录
#RUN python -c "from modelscope import snapshot_download; model_dir = snapshot_download('TaylorAI/gte-tiny'); import shutil; shutil.move(model_dir, '/app/models/gte-tiny')"
# 复制应用代码
COPY . .
# 暴露端口
EXPOSE 8001
# 健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8001/api/health || exit 1
# 启动命令 - 使用优化的统一启动脚本
CMD ["sh", "-c", "python3 start_unified.py --profile ${PROFILE:-balanced}"]