Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +129 -129
Dockerfile
CHANGED
|
@@ -1,129 +1,129 @@
|
|
| 1 |
-
FROM python:3.11-slim
|
| 2 |
-
|
| 3 |
-
LABEL maintainer="Hermes Agent Community"
|
| 4 |
-
LABEL version="0.10.0"
|
| 5 |
-
LABEL description="Hermes Agent v0.10.0 with Web UI on Hugging Face Spaces"
|
| 6 |
-
|
| 7 |
-
# ==================== 环境变量 ====================
|
| 8 |
-
ENV PYTHONUNBUFFERED=1
|
| 9 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
| 10 |
-
ENV HERMES_HOME=/data/.hermes
|
| 11 |
-
ENV PYTHONPATH=/app
|
| 12 |
-
|
| 13 |
-
# BFF Server 环境变量(构建阶段)
|
| 14 |
-
ENV PORT=7860
|
| 15 |
-
ENV UPSTREAM=http://127.0.0.1:8642
|
| 16 |
-
ENV HERMES_BIN=/usr/local/bin/hermes
|
| 17 |
-
# 注意:NODE_ENV=production 不能在此设置!
|
| 18 |
-
# npm install 在 NODE_ENV=production 时会跳过 devDependencies,
|
| 19 |
-
# 导致 vue-tsc 等构建工具缺失。NODE_ENV 在运行时阶段再设置。
|
| 20 |
-
|
| 21 |
-
# ==================== 系统依赖 ====================
|
| 22 |
-
RUN apt-get update && apt-get install -y \
|
| 23 |
-
build-essential \
|
| 24 |
-
ffmpeg \
|
| 25 |
-
git \
|
| 26 |
-
curl \
|
| 27 |
-
unzip \
|
| 28 |
-
ca-certificates \
|
| 29 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 30 |
-
|
| 31 |
-
# ==================== Node.js v23 ====================
|
| 32 |
-
# hermes-web-ui 要求 Node >= 23.0.0
|
| 33 |
-
RUN ARCH=$(dpkg --print-architecture) \
|
| 34 |
-
&& if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; else NODE_ARCH="$ARCH"; fi \
|
| 35 |
-
&& echo "Installing Node.js v23.11.0 for ${NODE_ARCH}" \
|
| 36 |
-
&& curl -fsSL "https://nodejs.org/dist/v23.11.0/node-v23.11.0-linux-${NODE_ARCH}.tar.gz" \
|
| 37 |
-
-o /tmp/node.tar.gz \
|
| 38 |
-
&& tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 \
|
| 39 |
-
&& rm -f /tmp/node.tar.gz \
|
| 40 |
-
&& node --version \
|
| 41 |
-
&& npm --version
|
| 42 |
-
|
| 43 |
-
# ==================== Bun Runtime ====================
|
| 44 |
-
# baoyu-skills 需要 bun 运行时
|
| 45 |
-
# 安装到 /usr/local/bin 以便所有用户(包括 appuser)都能访问
|
| 46 |
-
RUN echo "Installing Bun runtime" \
|
| 47 |
-
&& curl -fsSL https://bun.sh/install | bash \
|
| 48 |
-
&& export PATH="$PATH:/root/.bun/bin" \
|
| 49 |
-
&& bun --version \
|
| 50 |
-
&& cp /root/.bun/bin/bun /usr/local/bin/bun \
|
| 51 |
-
&& chmod +x /usr/local/bin/bun
|
| 52 |
-
|
| 53 |
-
# bun 必须在运行时 PATH 中可用(agent 子进程通过 bun 调用 baoyu-skills)
|
| 54 |
-
# /usr/local/bin 已在默认 PATH 中,所有用户均可访问
|
| 55 |
-
|
| 56 |
-
# ==================== baoyu-skills 脚本预置 ====================
|
| 57 |
-
# 将完整的 baoyu-imagine 脚本预置到 ~/.baoyu-skills/ 目录
|
| 58 |
-
# 此目录是 main.ts loadExtendConfig() 的查找路径之一
|
| 59 |
-
# 避免依赖 Web UI 技能安装(可能只下载编译产物而丢失 .ts 源文件)
|
| 60 |
-
RUN mkdir -p /home/appuser/.baoyu-skills/baoyu-imagine && \
|
| 61 |
-
git clone --depth 1 https://github.com/JimLiu/baoyu-skills.git /tmp/baoyu-skills && \
|
| 62 |
-
cp -r /tmp/baoyu-skills/skills/baoyu-image-gen/scripts \
|
| 63 |
-
/home/appuser/.baoyu-skills/baoyu-imagine/scripts && \
|
| 64 |
-
rm -rf /tmp/baoyu-skills
|
| 65 |
-
|
| 66 |
-
# ==================== 工具安装 ====================
|
| 67 |
-
# yq: 运行时修改 config.yaml
|
| 68 |
-
RUN curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/bin/yq && \
|
| 69 |
-
chmod +x /usr/bin/yq
|
| 70 |
-
|
| 71 |
-
# ==================== Python 依赖 ====================
|
| 72 |
-
COPY requirements.txt /tmp/
|
| 73 |
-
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 74 |
-
|
| 75 |
-
# ==================== Hermes Agent ====================
|
| 76 |
-
# 克隆并安装 Hermes Agent(不再构建内置 Dashboard 前端,由 hermes-web-ui 替代)
|
| 77 |
-
RUN git clone --depth 1 https://github.com/NousResearch/hermes-agent.git /tmp/hermes-agent && \
|
| 78 |
-
pip install --no-cache-dir /tmp/hermes-agent[all] && \
|
| 79 |
-
rm -rf /tmp/hermes-agent /root/.cache/pip
|
| 80 |
-
|
| 81 |
-
# Playwright 浏览器(Hermes Agent 工具调用需要)
|
| 82 |
-
RUN npx playwright install chromium --with-deps --only-shell
|
| 83 |
-
|
| 84 |
-
# ==================== Hermes Web UI ====================
|
| 85 |
-
# 克隆、构建、精简 hermes-web-ui(单层,避免中间态占用空间)
|
| 86 |
-
RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
|
| 87 |
-
cd /tmp/hermes-web-ui && \
|
| 88 |
-
npm pkg delete scripts.prepare && \
|
| 89 |
-
npm install && \
|
| 90 |
-
npm run build && \
|
| 91 |
-
npm prune --omit=dev && \
|
| 92 |
-
mkdir -p /opt/hermes-web-ui && \
|
| 93 |
-
cp -r dist node_modules package.json /opt/hermes-web-ui/ && \
|
| 94 |
-
rm -rf /tmp/hermes-web-ui /root/.npm
|
| 95 |
-
|
| 96 |
-
# ==================== 应用代码 ====================
|
| 97 |
-
WORKDIR /app
|
| 98 |
-
|
| 99 |
-
COPY src/ /app/src/
|
| 100 |
-
COPY entrypoint.sh /app/
|
| 101 |
-
COPY image-proxy.js /app/
|
| 102 |
-
COPY image-gen-siliconflow.ts /app/
|
| 103 |
-
COPY config/config.yaml /data/.hermes/config.yaml
|
| 104 |
-
|
| 105 |
-
# 创建数据目录
|
| 106 |
-
RUN mkdir -p /data/.hermes /data/.hermes-web-ui /app/logs /home/appuser/.hermes-web-ui/logs && \
|
| 107 |
-
chmod +x /app/entrypoint.sh
|
| 108 |
-
|
| 109 |
-
# 设置非 root 用户(Hugging Face Spaces 要求)
|
| 110 |
-
RUN useradd -m -u 1000 appuser && \
|
| 111 |
-
ln -sf /data/.hermes /home/appuser/.hermes && \
|
| 112 |
-
mkdir -p /home/appuser/.cache && \
|
| 113 |
-
chown -R appuser:appuser /data /opt/hermes-web-ui /app /home/appuser
|
| 114 |
-
|
| 115 |
-
USER appuser
|
| 116 |
-
|
| 117 |
-
# ==================== 运行时环境变量 ====================
|
| 118 |
-
# 构建阶段不设 NODE_ENV=production(会导致 npm install 跳过 devDependencies)
|
| 119 |
-
# 此处设置,仅影响运行时行为
|
| 120 |
-
ENV NODE_ENV=production
|
| 121 |
-
|
| 122 |
-
# 7860: BFF Server (Web UI 入口,HF Spaces 要求)
|
| 123 |
-
# 8642: Gateway API Server (BFF 的上游代理目标,仅容器内部)
|
| 124 |
-
EXPOSE 7860
|
| 125 |
-
|
| 126 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
|
| 127 |
-
CMD curl -f http://localhost:7860/health || exit 1
|
| 128 |
-
|
| 129 |
-
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
LABEL maintainer="Hermes Agent Community"
|
| 4 |
+
LABEL version="0.10.0"
|
| 5 |
+
LABEL description="Hermes Agent v0.10.0 with Web UI on Hugging Face Spaces"
|
| 6 |
+
|
| 7 |
+
# ==================== 环境变量 ====================
|
| 8 |
+
ENV PYTHONUNBUFFERED=1
|
| 9 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 10 |
+
ENV HERMES_HOME=/data/.hermes
|
| 11 |
+
ENV PYTHONPATH=/app
|
| 12 |
+
|
| 13 |
+
# BFF Server 环境变量(构建阶段)
|
| 14 |
+
ENV PORT=7860
|
| 15 |
+
ENV UPSTREAM=http://127.0.0.1:8642
|
| 16 |
+
ENV HERMES_BIN=/usr/local/bin/hermes
|
| 17 |
+
# 注意:NODE_ENV=production 不能在此设置!
|
| 18 |
+
# npm install 在 NODE_ENV=production 时会跳过 devDependencies,
|
| 19 |
+
# 导致 vue-tsc 等构建工具缺失。NODE_ENV 在运行时阶段再设置。
|
| 20 |
+
|
| 21 |
+
# ==================== 系统依赖 ====================
|
| 22 |
+
RUN apt-get update && apt-get install -y \
|
| 23 |
+
build-essential \
|
| 24 |
+
ffmpeg \
|
| 25 |
+
git \
|
| 26 |
+
curl \
|
| 27 |
+
unzip \
|
| 28 |
+
ca-certificates \
|
| 29 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 30 |
+
|
| 31 |
+
# ==================== Node.js v23 ====================
|
| 32 |
+
# hermes-web-ui 要求 Node >= 23.0.0
|
| 33 |
+
RUN ARCH=$(dpkg --print-architecture) \
|
| 34 |
+
&& if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; else NODE_ARCH="$ARCH"; fi \
|
| 35 |
+
&& echo "Installing Node.js v23.11.0 for ${NODE_ARCH}" \
|
| 36 |
+
&& curl -fsSL "https://nodejs.org/dist/v23.11.0/node-v23.11.0-linux-${NODE_ARCH}.tar.gz" \
|
| 37 |
+
-o /tmp/node.tar.gz \
|
| 38 |
+
&& tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 \
|
| 39 |
+
&& rm -f /tmp/node.tar.gz \
|
| 40 |
+
&& node --version \
|
| 41 |
+
&& npm --version
|
| 42 |
+
|
| 43 |
+
# ==================== Bun Runtime ====================
|
| 44 |
+
# baoyu-skills 需要 bun 运行时
|
| 45 |
+
# 安装到 /usr/local/bin 以便所有用户(包括 appuser)都能访问
|
| 46 |
+
RUN echo "Installing Bun runtime" \
|
| 47 |
+
&& curl -fsSL https://bun.sh/install | bash \
|
| 48 |
+
&& export PATH="$PATH:/root/.bun/bin" \
|
| 49 |
+
&& bun --version \
|
| 50 |
+
&& cp /root/.bun/bin/bun /usr/local/bin/bun \
|
| 51 |
+
&& chmod +x /usr/local/bin/bun
|
| 52 |
+
|
| 53 |
+
# bun 必须在运行时 PATH 中可用(agent 子进程通过 bun 调用 baoyu-skills)
|
| 54 |
+
# /usr/local/bin 已在默认 PATH 中,所有用户均可访问
|
| 55 |
+
|
| 56 |
+
# ==================== baoyu-skills 脚本预置 ====================
|
| 57 |
+
# 将完整的 baoyu-imagine 脚本预置到 ~/.baoyu-skills/ 目录
|
| 58 |
+
# 此目录是 main.ts loadExtendConfig() 的查找路径之一
|
| 59 |
+
# 避免依赖 Web UI 技能安装(可能只下载编译产物而丢失 .ts 源文件)
|
| 60 |
+
RUN mkdir -p /home/appuser/.baoyu-skills/baoyu-imagine && \
|
| 61 |
+
git clone --depth 1 https://github.com/JimLiu/baoyu-skills.git /tmp/baoyu-skills && \
|
| 62 |
+
cp -r /tmp/baoyu-skills/skills/baoyu-image-gen/scripts \
|
| 63 |
+
/home/appuser/.baoyu-skills/baoyu-imagine/scripts && \
|
| 64 |
+
rm -rf /tmp/baoyu-skills
|
| 65 |
+
|
| 66 |
+
# ==================== 工具安装 ====================
|
| 67 |
+
# yq: 运行时修改 config.yaml
|
| 68 |
+
RUN curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/bin/yq && \
|
| 69 |
+
chmod +x /usr/bin/yq
|
| 70 |
+
|
| 71 |
+
# ==================== Python 依赖 ====================
|
| 72 |
+
COPY requirements.txt /tmp/
|
| 73 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 74 |
+
|
| 75 |
+
# ==================== Hermes Agent ====================
|
| 76 |
+
# 克隆并安装 Hermes Agent(不再构建内置 Dashboard 前端,由 hermes-web-ui 替代)
|
| 77 |
+
RUN git clone --depth 1 https://github.com/NousResearch/hermes-agent.git /tmp/hermes-agent && \
|
| 78 |
+
pip install --no-cache-dir /tmp/hermes-agent[all] && \
|
| 79 |
+
rm -rf /tmp/hermes-agent /root/.cache/pip
|
| 80 |
+
|
| 81 |
+
# Playwright 浏览器(Hermes Agent 工具调用需要)
|
| 82 |
+
RUN npx playwright install chromium --with-deps --only-shell
|
| 83 |
+
|
| 84 |
+
# ==================== Hermes Web UI ====================
|
| 85 |
+
# 克隆、构建、精简 hermes-web-ui(单层,避免中间态占用空间)
|
| 86 |
+
RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
|
| 87 |
+
cd /tmp/hermes-web-ui && \
|
| 88 |
+
npm pkg delete scripts.prepare && \
|
| 89 |
+
npm install && \
|
| 90 |
+
npm run build && \
|
| 91 |
+
npm prune --omit=dev && \
|
| 92 |
+
mkdir -p /opt/hermes-web-ui && \
|
| 93 |
+
cp -r dist node_modules package.json /opt/hermes-web-ui/ && \
|
| 94 |
+
rm -rf /tmp/hermes-web-ui /root/.npm
|
| 95 |
+
|
| 96 |
+
# ==================== 应用代码 ====================
|
| 97 |
+
WORKDIR /app
|
| 98 |
+
|
| 99 |
+
COPY src/ /app/src/
|
| 100 |
+
COPY entrypoint.sh /app/
|
| 101 |
+
COPY image-proxy.js /app/
|
| 102 |
+
COPY image-gen-siliconflow.ts /app/
|
| 103 |
+
COPY config/config.yaml /data/.hermes/config.yaml
|
| 104 |
+
|
| 105 |
+
# 创建数据目录
|
| 106 |
+
RUN mkdir -p /data/.hermes /data/.hermes-web-ui /app/logs /home/appuser/.hermes-web-ui/logs && \
|
| 107 |
+
chmod +x /app/entrypoint.sh
|
| 108 |
+
|
| 109 |
+
# 设置非 root 用户(Hugging Face Spaces 要求)
|
| 110 |
+
RUN useradd -m -u 1000 appuser && \
|
| 111 |
+
ln -sf /data/.hermes /home/appuser/.hermes && \
|
| 112 |
+
mkdir -p /home/appuser/.cache && \
|
| 113 |
+
chown -R appuser:appuser /data /opt/hermes-web-ui /app /home/appuser
|
| 114 |
+
|
| 115 |
+
USER appuser
|
| 116 |
+
|
| 117 |
+
# ==================== 运行时环境变量 ====================
|
| 118 |
+
# 构建阶段不设 NODE_ENV=production(会导致 npm install 跳过 devDependencies)
|
| 119 |
+
# 此处设置,仅影响运行时行为
|
| 120 |
+
ENV NODE_ENV=production
|
| 121 |
+
|
| 122 |
+
# 7860: BFF Server (Web UI 入口,HF Spaces 要求)
|
| 123 |
+
# 8642: Gateway API Server (BFF 的上游代理目标,仅容器内部)
|
| 124 |
+
EXPOSE 7860
|
| 125 |
+
|
| 126 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
|
| 127 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 128 |
+
|
| 129 |
+
ENTRYPOINT ["/app/entrypoint.sh"]
|