qwen_agent/Dockerfile
朱潮 cb649d83ee Merge branch 'developing' into bot_manager
# Conflicts:
#	.features/skill/MEMORY.md
#	poetry.lock
#	requirements.txt
2026-06-08 20:07:30 +08:00

78 lines
2.6 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 python:3.12-slim AS base
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# 安装系统依赖(含 LibreOffice 和 sharp 所需的 libvips
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
gnupg2 \
ca-certificates \
libpq-dev \
chromium \
ffmpeg \
libreoffice-writer-nogui \
libreoffice-calc-nogui \
libreoffice-impress-nogui \
libvips-dev \
fonts-noto-cjk \
&& rm -rf /var/lib/apt/lists/*
# 安装Node.js (支持npx命令)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*
# 安装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 grep -Ev '^(torch|triton|nvidia-[^=]+|sentence-transformers|transformers|tokenizers|safetensors|scikit-learn|scipy|huggingface-hub|hf-xet)==' requirements.txt > /tmp/requirements.runtime.txt && \
! grep -E '^(torch|triton|nvidia-[^=]+|sentence-transformers|transformers|tokenizers|safetensors|scikit-learn|scipy|huggingface-hub|hf-xet)==' /tmp/requirements.runtime.txt && \
pip install --no-cache-dir -r /tmp/requirements.runtime.txt && \
rm -f /tmp/requirements.runtime.txt
# 安装 Playwright 并下载 Chromium
RUN pip install --no-cache-dir playwright && \
playwright install chromium
RUN npm install -g playwright sharp nodemailer dotenv && \
npx playwright install chromium
# 创建必要的目录
RUN mkdir -p /app/projects
RUN mkdir -p /app/public
RUN mkdir -p /app/models
FROM base AS bytecode-builder
# 复制应用代码,仅在构建阶段编译为字节码
COPY . .
RUN python -m compileall -b -x '(/projects/|/skills/)' /app && \
find /app -not -path '/app/projects/*' -not -path '/app/skills/*' -type f -name '*.py' -delete && \
find /app -not -path '/app/projects/*' -not -path '/app/skills/*' -type d -name '__pycache__' -prune -exec rm -rf {} +
FROM base AS runtime
# 只复制编译后的应用文件,避免源码进入最终镜像层
COPY --from=bytecode-builder /app /app
# 暴露端口
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.pyc --profile ${PROFILE:-balanced}"]