Update Dockerfile
Browse files- Dockerfile +25 -3
Dockerfile
CHANGED
@@ -5,7 +5,7 @@ FROM python:3.9
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
# 安装系统依赖
|
8 |
-
RUN apt-get update && apt-get install -y curl sudo fontconfig
|
9 |
|
10 |
# 设置所有环境变量到 /tmp 目录下
|
11 |
ENV OLLAMA_HOME=/.ollama
|
@@ -32,12 +32,34 @@ RUN curl -L https://ollama.ai/install.sh | sh
|
|
32 |
# 安装Gradio及其依赖
|
33 |
RUN pip install gradio requests
|
34 |
|
35 |
-
#
|
36 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# 将当前目录下的所有文件复制到容器内的/app目录
|
39 |
COPY . /app
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# 添加启动脚本并设置执行权限
|
42 |
COPY start.sh /app/start.sh
|
43 |
RUN chmod +x /app/start.sh
|
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
# 安装系统依赖
|
8 |
+
RUN apt-get update && apt-get install -y curl sudo fontconfig wget
|
9 |
|
10 |
# 设置所有环境变量到 /tmp 目录下
|
11 |
ENV OLLAMA_HOME=/.ollama
|
|
|
32 |
# 安装Gradio及其依赖
|
33 |
RUN pip install gradio requests
|
34 |
|
35 |
+
# 下载模型文件(使用wget并添加重试机制)
|
36 |
+
RUN wget --tries=3 --retry-connrefused --waitretry=5 --timeout=30 \
|
37 |
+
-O /app/model.gguf \
|
38 |
+
https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat/resolve/main/gguf/llama3.1_8b_chinese_chat_q4_0.gguf
|
39 |
+
|
40 |
+
# 验证文件是否为GGUF格式
|
41 |
+
RUN python3 -c '
|
42 |
+
import sys
|
43 |
+
def is_gguf(file_path):
|
44 |
+
with open(file_path, "rb") as f:
|
45 |
+
magic = f.read(4)
|
46 |
+
return magic == b"GGUF"
|
47 |
+
if not is_gguf("/app/model.gguf"):
|
48 |
+
print("Error: Downloaded file is not in GGUF format")
|
49 |
+
sys.exit(1)
|
50 |
+
'
|
51 |
|
52 |
# 将当前目录下的所有文件复制到容器内的/app目录
|
53 |
COPY . /app
|
54 |
|
55 |
+
# 创建新的Modelfile
|
56 |
+
RUN echo "FROM /app/model.gguf\n\
|
57 |
+
PARAMETER stop \"Human:\"\n\
|
58 |
+
PARAMETER stop \"Assistant:\"\n\
|
59 |
+
PARAMETER temperature 0.7\n\
|
60 |
+
PARAMETER top_k 40\n\
|
61 |
+
PARAMETER top_p 0.9" > /app/Modelfile
|
62 |
+
|
63 |
# 添加启动脚本并设置执行权限
|
64 |
COPY start.sh /app/start.sh
|
65 |
RUN chmod +x /app/start.sh
|