-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (39 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
49 lines (39 loc) · 1.27 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
FROM python:3.12-slim
# 安装curl用于健康检查
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# 设置环境变量 - 强化编码支持
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=utf-8
ENV PYTHONLEGACYWINDOWSSTDIO=0
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# 设置工作目录
WORKDIR /app
# 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY k2think_proxy.py .
COPY get_tokens.py .
COPY src/ ./src/
# 创建数据目录和默认文件
RUN mkdir -p /app/data && \
touch /app/data/tokens.txt && \
echo "# Token文件将由自动更新服务生成" > /app/data/tokens.txt && \
touch /app/data/accounts.txt && \
echo "# 请通过volume挂载实际的accounts.txt文件" > /app/data/accounts.txt
# 创建简单的启动脚本
RUN echo '#!/bin/bash\n\
# 确保数据目录存在\n\
mkdir -p /app/data\n\
# 直接运行应用\n\
exec "$@"' > /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
# 暴露端口
EXPOSE 8001
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8001/health || exit 1
# 设置entrypoint和默认命令
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["python", "k2think_proxy.py"]