-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (69 loc) · 2.02 KB
/
Copy pathDockerfile
File metadata and controls
86 lines (69 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# AI-Dev-Insight 后端服务 Dockerfile
# 基于 Python 3.12 官方镜像构建
FROM python:3.12-slim
# 添加标签信息
LABEL maintainer="AI-Dev-Insight Team"
LABEL description="AI-Dev-Insight Backend Service"
LABEL version="1.0.0"
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
curl \
default-mysql-client \
libnss3 \
libnspr4 \
libatk-bridge2.0-0 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libxss1 \
libasound2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# 安装 uv (现代化 Python 包管理器)
RUN pip install --no-cache-dir uv
# 复制项目配置文件(利用Docker缓存层优化)
COPY pyproject.toml uv.lock* ./
# 使用 uv 安装 Python 依赖
RUN uv sync --frozen --no-dev
# 安装 Playwright 浏览器(合并为单个RUN层)-- 外部导入数据,不进行爬虫
# RUN uv run playwright install chromium && \
# uv run playwright install-deps
# 复制应用代码
COPY . .
# 创建必要的目录
RUN mkdir -p logs static/uploads/images
# 设置默认环境变量(非敏感信息)
ENV APP_NAME="AI-Dev-Insight" \
VERSION="1.0.0" \
ENVIRONMENT="production" \
DEBUG="false" \
HOST="0.0.0.0" \
PORT="8000" \
LLM_PROVIDER="openai" \
OPENAI_API_BASE="https://api.openai.com/v1" \
LLM_MODEL="gpt-4o-mini" \
LOG_LEVEL="INFO"
# 暴露端口
EXPOSE 8000
# 复制启动脚本
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
# 设置启动脚本权限
RUN chmod +x /app/docker-entrypoint.sh
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:$PORT/health || exit 1
# 启动命令
ENTRYPOINT ["/app/docker-entrypoint.sh"]