第二版
This commit is contained in:
42
Dockerfile
42
Dockerfile
@@ -1,7 +1,8 @@
|
||||
# Multi-Agent Software Delivery System
|
||||
# 基于 CrewAI + Qwen3.5-flash 的多智能体软件交付系统
|
||||
# 多阶段构建 - SDLC Agent Demo
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
FROM python:3.11-slim
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置环境变量
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
@@ -9,29 +10,28 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
# 安装依赖
|
||||
COPY requirements.txt .
|
||||
RUN pip install --user --no-cache-dir -r requirements.txt
|
||||
|
||||
# 运行阶段
|
||||
FROM python:3.11-slim
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# 从 builder 阶段复制安装的包
|
||||
COPY --from=builder /root/.local /root/.local
|
||||
|
||||
# 复制依赖文件
|
||||
COPY requirements.txt .
|
||||
|
||||
# 安装 Python 依赖
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# 确保脚本路径在 PATH 中
|
||||
ENV PATH=/root/.local/bin:$PATH \
|
||||
PYTHONPATH=/app
|
||||
|
||||
# 复制应用代码
|
||||
COPY main.py .
|
||||
COPY crew_factory.py .
|
||||
COPY agents_config.py .
|
||||
COPY stream_manager.py .
|
||||
COPY .env.example .env.example
|
||||
COPY . .
|
||||
|
||||
# 创建非 root 用户运行应用
|
||||
RUN useradd --create-home --shell /bin/bash appuser && \
|
||||
# 创建非 root 用户
|
||||
RUN useradd -m -u 1000 appuser && \
|
||||
chown -R appuser:appuser /app
|
||||
USER appuser
|
||||
|
||||
@@ -40,7 +40,7 @@ EXPOSE 8000
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
|
||||
CMD python -c "import httpx; httpx.get('http://localhost:8000/health')" || exit 1
|
||||
|
||||
# 启动命令
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
||||
Reference in New Issue
Block a user