web / Dockerfile
nbugs's picture
Update Dockerfile
d1a7f47 verified
raw
history blame
2.07 kB
# 使用基础镜像
FROM ghcr.io/open-webui/open-webui:main
# 设置工作目录
WORKDIR /app
# 安装依赖(python3, pip, curl),安装 Python 包,并清理apt缓存
# DEBIAN_FRONTEND=noninteractive 避免交互式提示
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y --no-install-recommends python3 python3-pip curl && \
pip3 install --no-cache-dir huggingface_hub && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 复制 Python 同步脚本
COPY hf_sync.py /app/hf_sync.py
# 复制主同步脚本
COPY sync_data.sh /app/sync_data.sh
# 复制自定义入口点脚本
COPY entrypoint.sh /app/entrypoint.sh
# 复制自定义资源文件
# !! 注意:请确认 /app/build/assets 是基础镜像中存放前端资源的正确路径 !!
COPY custom.css /app/build/assets/
COPY custom.js /app/build/assets/
COPY editor.css /app/build/assets/
COPY editor.js /app/build/assets/
# 向 index.html 注入 CSS/JS 引用
# !! 注意:请确认 /app/build/index.html 是基础镜像中主HTML文件的正确路径 !!
# 如果文件不存在,RUN命令会失败,这有助于发现路径错误
RUN if [ -f /app/build/index.html ]; then \
sed -i \
-e 's|</head>|<link rel="stylesheet" href="assets/editor.css">\n</head>|' \
-e 's|</body>|<script src="assets/editor.js"></script>\n</body>|' \
-e 's|</head>|<link rel="stylesheet" href="assets/custom.css">\n</head>|' \
-e 's|</body>|<script src="assets/custom.js"></script>\n</body>|' \
/app/build/index.html; \
else \
echo "警告:未找到 /app/build/index.html,跳过注入CSS/JS。"; \
fi
# 设置脚本执行权限
RUN chmod +x /app/sync_data.sh && \
chmod +x /app/hf_sync.py && \
chmod +x /app/entrypoint.sh
# 设置入口点
ENTRYPOINT ["/app/entrypoint.sh"]
# 保留基础镜像的 CMD。 entrypoint.sh 脚本最后会用 exec "$@" 执行它。
# 例如,如果基础镜像是 CMD ["/app/start.sh"],entrypoint.sh 会最终执行 /app/start.sh