forked from shaxiu/XianyuAutoAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (50 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
64 lines (50 loc) · 1.62 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
FROM python:3.10-alpine AS builder
WORKDIR /app
# 只安装构建所需的依赖
RUN apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
libffi-dev \
build-base
# 创建虚拟环境并安装依赖
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 第二阶段:最终镜像
FROM python:3.10-alpine
# 添加元数据标签
LABEL maintainer="coderxiu<coderxiu@qq.com>"
LABEL description="闲鱼AI客服机器人"
LABEL version="2.0"
# 设置时区和编码
ENV TZ=Asia/Shanghai \
PYTHONIOENCODING=utf-8 \
LANG=C.UTF-8 \
PATH="/opt/venv/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# 只安装运行时必要的包
RUN apk add --no-cache \
tzdata \
&& ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo Asia/Shanghai > /etc/timezone \
# 清理apk缓存
&& rm -rf /var/cache/apk/*
# 设置工作目录
WORKDIR /app
# 从构建阶段复制虚拟环境
COPY --from=builder /opt/venv /opt/venv
# 创建必要的目录
RUN mkdir -p data prompts
# 复制示例提示词文件并重命名为正式文件
COPY prompts/classify_prompt_example.txt prompts/classify_prompt.txt
COPY prompts/price_prompt_example.txt prompts/price_prompt.txt
COPY prompts/tech_prompt_example.txt prompts/tech_prompt.txt
COPY prompts/default_prompt_example.txt prompts/default_prompt.txt
# 只复制绝对必要的文件
COPY main.py XianyuAgent.py XianyuApis.py context_manager.py ./
COPY utils/ utils/
# 容器启动时运行的命令
CMD ["python", "main.py"]