Spaces:
Running
Running
Z User commited on
Commit ·
946e383
1
Parent(s): a8cb5b7
fix: hermes-web-ui build (add esbuild) + dual-process (gateway + Node.js BFF)
Browse files- Fix Dockerfile: add 'npm install esbuild' before 'npm run build' to resolve missing dependency
- Output webui dist to /app/dist/ (server + client) maintaining relative paths
- New start.sh: start hermes gateway on 8642, then Node.js BFF on 7860
- Remove Node.js build tools after build to save ~300MB
- Hermes gateway runs as background process, Node.js as foreground
- Added gateway readiness check before starting webui server
- Dockerfile +15 -19
- start.sh +25 -15
Dockerfile
CHANGED
|
@@ -1,28 +1,24 @@
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
-
# System deps (
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
git curl gnupg2 fontconfig make g++ \
|
| 6 |
-
&&
|
| 7 |
-
|
| 8 |
-
# Install Node.js 23
|
| 9 |
-
RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash - \
|
| 10 |
&& apt-get install -y --no-install-recommends nodejs \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
-
# Clone hermes-agent
|
| 16 |
RUN git clone --depth 1 https://github.com/NousResearch/hermes-agent.git /app/hermes-agent
|
| 17 |
|
| 18 |
-
# Build Python venv
|
| 19 |
RUN python3 -m venv /app/venv
|
| 20 |
ENV PATH="/app/venv/bin:/usr/local/bin:$PATH"
|
| 21 |
RUN pip install --quiet --upgrade pip && \
|
| 22 |
pip install --quiet psutil networkx && \
|
| 23 |
-
pip install --quiet -e "/app/hermes-agent[feishu,mcp,cron
|
| 24 |
|
| 25 |
-
# Chinese font (Noto Sans SC
|
| 26 |
RUN mkdir -p /usr/share/fonts/truetype/noto && \
|
| 27 |
curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Regular.otf" \
|
| 28 |
-o /usr/share/fonts/truetype/noto/NotoSansSC-Regular.otf && \
|
|
@@ -30,39 +26,39 @@ RUN mkdir -p /usr/share/fonts/truetype/noto && \
|
|
| 30 |
-o /usr/share/fonts/truetype/noto/NotoSansSC-Bold.otf && \
|
| 31 |
fc-cache -f
|
| 32 |
|
| 33 |
-
# ── Build hermes-web-ui ──
|
| 34 |
RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
|
| 35 |
cd /tmp/hermes-web-ui && \
|
| 36 |
npm install --quiet 2>&1 | tail -5 && \
|
|
|
|
| 37 |
npm run build 2>&1 | tail -10 && \
|
| 38 |
-
|
| 39 |
-
cp dist/
|
|
|
|
| 40 |
rm -rf /tmp/hermes-web-ui && \
|
| 41 |
echo "WebUI build complete"
|
| 42 |
|
| 43 |
-
# Cleanup build tools (save ~
|
| 44 |
-
RUN apt-get purge -y --auto-remove make g++ && rm -rf /var/lib/apt/lists/*
|
| 45 |
|
| 46 |
-
#
|
| 47 |
RUN mkdir -p /root/.hermes/plugins/image_gen/pollinations
|
| 48 |
|
| 49 |
-
# Copy config files
|
| 50 |
COPY config.yaml /root/.hermes/config.yaml
|
| 51 |
COPY SOUL.md /root/.hermes/SOUL.md
|
| 52 |
COPY .env /root/.hermes/.env
|
| 53 |
-
COPY entry.py /app/entry.py
|
| 54 |
-
COPY dashboard.html /app/dashboard.html
|
| 55 |
COPY plugins/pollinations/ /root/.hermes/plugins/image_gen/pollinations/
|
| 56 |
COPY scripts/ /app/scripts/
|
| 57 |
|
| 58 |
RUN chmod 600 /root/.hermes/.env
|
| 59 |
|
| 60 |
-
# Startup script
|
| 61 |
COPY start.sh /app/start.sh
|
| 62 |
RUN chmod +x /app/start.sh
|
| 63 |
|
| 64 |
EXPOSE 7860
|
| 65 |
|
| 66 |
ENV HERMES_ACCEPT_HOOKS=1
|
|
|
|
|
|
|
| 67 |
|
| 68 |
CMD ["/app/start.sh"]
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
+
# System deps (Node.js 23 + build tools for native modules)
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
git curl gnupg2 fontconfig make g++ \
|
| 6 |
+
&& curl -fsSL https://deb.nodesource.com/setup_23.x | bash - \
|
|
|
|
|
|
|
|
|
|
| 7 |
&& apt-get install -y --no-install-recommends nodejs \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
+
# ── 1. Clone & install hermes-agent (Python gateway) ──
|
| 13 |
RUN git clone --depth 1 https://github.com/NousResearch/hermes-agent.git /app/hermes-agent
|
| 14 |
|
|
|
|
| 15 |
RUN python3 -m venv /app/venv
|
| 16 |
ENV PATH="/app/venv/bin:/usr/local/bin:$PATH"
|
| 17 |
RUN pip install --quiet --upgrade pip && \
|
| 18 |
pip install --quiet psutil networkx && \
|
| 19 |
+
pip install --quiet -e "/app/hermes-agent[feishu,mcp,cron]" 2>&1 | tail -10
|
| 20 |
|
| 21 |
+
# Chinese font (Noto Sans SC, ~16MB)
|
| 22 |
RUN mkdir -p /usr/share/fonts/truetype/noto && \
|
| 23 |
curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Regular.otf" \
|
| 24 |
-o /usr/share/fonts/truetype/noto/NotoSansSC-Regular.otf && \
|
|
|
|
| 26 |
-o /usr/share/fonts/truetype/noto/NotoSansSC-Bold.otf && \
|
| 27 |
fc-cache -f
|
| 28 |
|
| 29 |
+
# ── 2. Build hermes-web-ui (Vue SPA + Node.js BFF) ──
|
| 30 |
RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
|
| 31 |
cd /tmp/hermes-web-ui && \
|
| 32 |
npm install --quiet 2>&1 | tail -5 && \
|
| 33 |
+
npm install --save-dev esbuild --quiet 2>&1 | tail -3 && \
|
| 34 |
npm run build 2>&1 | tail -10 && \
|
| 35 |
+
mkdir -p /app/dist && \
|
| 36 |
+
cp -r dist/client /app/dist/client && \
|
| 37 |
+
cp dist/server/index.js /app/dist/server/ && \
|
| 38 |
rm -rf /tmp/hermes-web-ui && \
|
| 39 |
echo "WebUI build complete"
|
| 40 |
|
| 41 |
+
# ── 3. Cleanup build tools (save ~300MB) ──
|
| 42 |
+
RUN apt-get purge -y --auto-remove make g++ gnupg2 && rm -rf /var/lib/apt/lists/*
|
| 43 |
|
| 44 |
+
# ── 4. App config ──
|
| 45 |
RUN mkdir -p /root/.hermes/plugins/image_gen/pollinations
|
| 46 |
|
|
|
|
| 47 |
COPY config.yaml /root/.hermes/config.yaml
|
| 48 |
COPY SOUL.md /root/.hermes/SOUL.md
|
| 49 |
COPY .env /root/.hermes/.env
|
|
|
|
|
|
|
| 50 |
COPY plugins/pollinations/ /root/.hermes/plugins/image_gen/pollinations/
|
| 51 |
COPY scripts/ /app/scripts/
|
| 52 |
|
| 53 |
RUN chmod 600 /root/.hermes/.env
|
| 54 |
|
|
|
|
| 55 |
COPY start.sh /app/start.sh
|
| 56 |
RUN chmod +x /app/start.sh
|
| 57 |
|
| 58 |
EXPOSE 7860
|
| 59 |
|
| 60 |
ENV HERMES_ACCEPT_HOOKS=1
|
| 61 |
+
ENV PORT=7860
|
| 62 |
+
ENV UPSTREAM=http://127.0.0.1:8642
|
| 63 |
|
| 64 |
CMD ["/app/start.sh"]
|
start.sh
CHANGED
|
@@ -1,32 +1,42 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
-
#
|
| 5 |
mkdir -p /data/hermes/{sessions,memories,uploads,logs,palace,skills}
|
| 6 |
|
| 7 |
-
# Create symlinks from hermes home to persistent storage
|
| 8 |
HERMES_HOME="/root/.hermes"
|
| 9 |
for dir in sessions memories uploads logs palace skills; do
|
| 10 |
target="$HERMES_HOME/$dir"
|
| 11 |
if [ ! -L "$target" ] && [ ! -d "$target" ]; then
|
| 12 |
ln -sf "/data/hermes/$dir" "$target"
|
| 13 |
-
echo "
|
| 14 |
elif [ -L "$target" ]; then
|
| 15 |
echo "Symlink exists: $dir"
|
| 16 |
fi
|
| 17 |
done
|
| 18 |
-
|
| 19 |
echo "Persistent storage ready."
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
+
# ── Persistent storage ──
|
| 5 |
mkdir -p /data/hermes/{sessions,memories,uploads,logs,palace,skills}
|
| 6 |
|
|
|
|
| 7 |
HERMES_HOME="/root/.hermes"
|
| 8 |
for dir in sessions memories uploads logs palace skills; do
|
| 9 |
target="$HERMES_HOME/$dir"
|
| 10 |
if [ ! -L "$target" ] && [ ! -d "$target" ]; then
|
| 11 |
ln -sf "/data/hermes/$dir" "$target"
|
| 12 |
+
echo "Symlink: $dir -> /data/hermes/$dir"
|
| 13 |
elif [ -L "$target" ]; then
|
| 14 |
echo "Symlink exists: $dir"
|
| 15 |
fi
|
| 16 |
done
|
|
|
|
| 17 |
echo "Persistent storage ready."
|
| 18 |
|
| 19 |
+
# ── Start hermes gateway on port 8642 (background) ──
|
| 20 |
+
mkdir -p "$HERMES_HOME/logs"
|
| 21 |
+
echo "Starting hermes gateway..."
|
| 22 |
+
python3 -u -m hermes_cli.main gateway run -v \
|
| 23 |
+
>> "$HERMES_HOME/logs/gateway.log" 2>&1 &
|
| 24 |
+
GATEWAY_PID=$!
|
| 25 |
+
echo "Gateway PID: $GATEWAY_PID"
|
| 26 |
+
|
| 27 |
+
# Wait for gateway to be ready (check port 8642)
|
| 28 |
+
for i in $(seq 1 30); do
|
| 29 |
+
if python3 -c "import socket; s=socket.socket(); s.settimeout(1); s.connect(('127.0.0.1', 8642)); s.close()" 2>/dev/null; then
|
| 30 |
+
echo "Gateway ready on port 8642"
|
| 31 |
+
break
|
| 32 |
+
fi
|
| 33 |
+
if [ $i -eq 30 ]; then
|
| 34 |
+
echo "WARNING: Gateway did not start in time, continuing anyway"
|
| 35 |
+
fi
|
| 36 |
+
sleep 1
|
| 37 |
+
done
|
| 38 |
|
| 39 |
+
# ── Start Node.js webui server on port 7860 (foreground) ──
|
| 40 |
+
echo "Starting hermes-web-ui on port ${PORT:-7860}..."
|
| 41 |
+
export NODE_ENV=production
|
| 42 |
+
exec node /app/dist/server/index.js
|