supeng 2 недель назад
Родитель
Сommit
b54270dafd

+ 3 - 2
examples/auto_put_ad_mini/.dockerignore

@@ -31,8 +31,9 @@ outputs/*
 .env.*.local
 
 # Documentation (除了README)
-*.md
-!README.md
+# 注意:Dockerfile 会复制 *.md 文件,所以这里不排除
+# *.md
+# !README.md
 
 # Node
 node_modules/

+ 8 - 11
examples/auto_put_ad_mini/Dockerfile

@@ -1,23 +1,20 @@
 # 使用官方 Python 3.10 slim 镜像
-FROM python:3.10-slim
+FROM registry.cn-hangzhou.aliyuncs.com/stuuudy/python:3.13-slim
 
 # 设置工作目录
 WORKDIR /app
 
-# 安装系统依赖(ODPS、SSL等)
-RUN apt-get update && apt-get install -y \
-    gcc \
-    g++ \
-    libssl-dev \
-    libffi-dev \
-    curl \
+# 安装系统依赖(使用阿里云镜像源)
+RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends curl \
     && rm -rf /var/lib/apt/lists/*
 
 # 复制依赖文件
 COPY examples/auto_put_ad_mini/requirements.txt .
 
-# 安装 Python 依赖
-RUN pip install --no-cache-dir -r requirements.txt
+# 安装 Python 依赖(使用阿里云 PyPI 镜像)
+RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
 
 # 复制 Agent 框架(从项目根目录)
 COPY agent /app/agent
@@ -43,7 +40,7 @@ ENV PYTHONUNBUFFERED=1 \
 EXPOSE 8080
 
 # 健康检查(使用 FastAPI 端点,如果可用)
-HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
+HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
     CMD curl -f http://localhost:8080/health || python -c "import pathlib; pathlib.Path('/app/outputs').exists()" || exit 1
 
 # 默认命令:启动 FastAPI 服务器(而非单次执行)

+ 4 - 4
examples/auto_put_ad_mini/docker-compose.yml

@@ -1,5 +1,3 @@
-version: '3.8'
-
 services:
   auto_put_ad_mini:
     build:
@@ -16,7 +14,9 @@ services:
       - "8080:8080"  # 暴露FastAPI端口
     volumes:
       - ./outputs:/app/outputs  # 持久化输出
-      - ./config.py:/app/config.py  # 热更新配置(可选)
+      # 注意:单文件挂载有风险,如果文件不存在 Docker 会创建同名目录导致启动失败
+      # 如需热更新配置,请确保 config.py 存在后再取消注释:
+      # - ./config.py:/app/config.py
     networks:
       - ad_network
     restart: unless-stopped
@@ -25,7 +25,7 @@ services:
       interval: 30s
       timeout: 10s
       retries: 3
-      start_period: 10s
+      start_period: 40s
 
 networks:
   ad_network: