Update Dockerfile
Browse files- Dockerfile +21 -53
Dockerfile
CHANGED
@@ -1,55 +1,23 @@
|
|
1 |
-
# 使用基础镜像
|
2 |
FROM ghcr.io/open-webui/open-webui:main
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
# 复制自定义资源文件
|
26 |
-
# !! 注意:请确认 /app/build/assets 是基础镜像中存放前端资源的正确路径 !!
|
27 |
-
COPY custom.css /app/build/assets/
|
28 |
-
COPY custom.js /app/build/assets/
|
29 |
-
COPY editor.css /app/build/assets/
|
30 |
-
COPY editor.js /app/build/assets/
|
31 |
-
|
32 |
-
# 向 index.html 注入 CSS/JS 引用
|
33 |
-
# !! 注意:请确认 /app/build/index.html 是基础镜像中主HTML文件的正确路径 !!
|
34 |
-
# 如果文件不存在,RUN命令会失败,这有助于发现路径错误
|
35 |
-
RUN if [ -f /app/build/index.html ]; then \
|
36 |
-
sed -i \
|
37 |
-
-e 's|</head>|<link rel="stylesheet" href="assets/editor.css">\n</head>|' \
|
38 |
-
-e 's|</body>|<script src="assets/editor.js"></script>\n</body>|' \
|
39 |
-
-e 's|</head>|<link rel="stylesheet" href="assets/custom.css">\n</head>|' \
|
40 |
-
-e 's|</body>|<script src="assets/custom.js"></script>\n</body>|' \
|
41 |
-
/app/build/index.html; \
|
42 |
-
else \
|
43 |
-
echo "警告:未找到 /app/build/index.html,跳过注入CSS/JS。"; \
|
44 |
-
fi
|
45 |
-
|
46 |
-
# 设置脚本执行权限
|
47 |
-
RUN chmod +x /app/sync_data.sh && \
|
48 |
-
chmod +x /app/hf_sync.py && \
|
49 |
-
chmod +x /app/entrypoint.sh
|
50 |
-
|
51 |
-
# 设置入口点
|
52 |
-
ENTRYPOINT ["/app/entrypoint.sh"]
|
53 |
-
|
54 |
-
# 保留基础镜像的 CMD。 entrypoint.sh 脚本最后会用 exec "$@" 执行它。
|
55 |
-
# 例如,如果基础镜像是 CMD ["/app/start.sh"],entrypoint.sh 会最终执行 /app/start.sh
|
|
|
|
|
1 |
FROM ghcr.io/open-webui/open-webui:main
|
2 |
|
3 |
+
# 合并安装命令并清理缓存
|
4 |
+
RUN apt-get update && apt-get install -y python3 python3-pip \
|
5 |
+
&& pip3 install --no-cache-dir huggingface_hub \
|
6 |
+
&& apt-get clean \
|
7 |
+
&& rm -rf /var/lib/apt/lists/*
|
8 |
+
|
9 |
+
# 复制文件
|
10 |
+
COPY sync_data.sh ./
|
11 |
+
COPY custom.css custom.js editor.css editor.js /app/build/assets/
|
12 |
+
|
13 |
+
# 优化 sed 命令,一次性处理 HTML 修改
|
14 |
+
RUN sed -i \
|
15 |
+
-e '/<\/head>/i <link rel="stylesheet" href="assets/editor.css">' \
|
16 |
+
-e '/<\/head>/i <link rel="stylesheet" href="assets/custom.css">' \
|
17 |
+
-e '/<\/body>/i <script src="assets/editor.js"></script>' \
|
18 |
+
-e '/<\/body>/i <script src="assets/custom.js"></script>' \
|
19 |
+
/app/build/index.html \
|
20 |
+
&& chmod -R 777 ./data \
|
21 |
+
&& chmod -R 777 /app/backend/open_webui/static \
|
22 |
+
&& chmod +x sync_data.sh \
|
23 |
+
&& sed -i "1r sync_data.sh" ./start.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|