AutoFix commited on
Commit
8aa2a43
·
1 Parent(s): 8d9879d

fix: revert to single-stage Dockerfile for stability

Browse files

The multi-stage build caused HF Space routing issues — the container
showed RUNNING but traffic wasn't forwarded to port 7860 (404).
Reverting to proven single-stage build while we investigate.

Files changed (1) hide show
  1. Dockerfile +17 -47
Dockerfile CHANGED
@@ -1,9 +1,6 @@
1
- # ============================================================
2
- # Stage 1: Builder — clone, build, patch (discarded after)
3
- # ============================================================
4
- FROM python:3.12-slim AS builder
5
 
6
- # Build tools needed for node-pty native compilation
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  git curl gnupg2 fontconfig make g++ python3 \
9
  && rm -rf /var/lib/apt/lists/*
@@ -20,29 +17,41 @@ RUN pip install --quiet --upgrade pip && \
20
  pip install --quiet psutil networkx && \
21
  pip install --quiet -e "/app/hermes-agent[feishu,mcp,cron,pty]" 2>&1 | tail -10
22
 
23
- # All patches (non-fatal won't break build if upstream changed)
24
  COPY scripts/patch_file_delivery.py /tmp/patch_file_delivery.py
25
  RUN python3 /tmp/patch_file_delivery.py; rm -f /tmp/patch_file_delivery.py
26
 
 
27
  COPY patches/hermes-agent/agent/prompt_builder.py /app/hermes-agent/agent/prompt_builder.py
28
  COPY patches/hermes-agent/tools/send_message_tool.py /app/hermes-agent/tools/send_message_tool.py
29
 
 
30
  COPY scripts/patch_auto_media.py /tmp/patch_auto_media.py
31
  RUN python3 /tmp/patch_auto_media.py; rm -f /tmp/patch_auto_media.py
32
 
 
33
  COPY scripts/patch_resolve_media_paths.py /tmp/patch_resolve_media_paths.py
34
  RUN python3 /tmp/patch_resolve_media_paths.py; rm -f /tmp/patch_resolve_media_paths.py
35
 
36
- # Install Node.js 23 for web-ui build
37
  RUN ARCH=$(dpkg --print-architecture) \
38
  && if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; else NODE_ARCH="$ARCH"; fi \
 
39
  && curl -fsSL "https://nodejs.org/dist/v23.11.0/node-v23.11.0-linux-${NODE_ARCH}.tar.gz" \
40
  -o /tmp/node.tar.gz \
41
  && tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 \
42
  && rm -f /tmp/node.tar.gz \
43
  && node --version && npm --version
44
 
45
- # Build hermes-web-ui
 
 
 
 
 
 
 
 
46
  RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
47
  cd /tmp/hermes-web-ui && \
48
  npm install --ignore-scripts 2>&1 | tail -5 && \
@@ -57,45 +66,6 @@ RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/he
57
  rm -rf /tmp/hermes-web-ui && \
58
  echo "hermes-web-ui build done"
59
 
60
-
61
- # ============================================================
62
- # Stage 2: Runtime — minimal image with only what's needed
63
- # ============================================================
64
- FROM python:3.12-slim
65
-
66
- # Runtime deps only (no build tools)
67
- RUN apt-get update && apt-get install -y --no-install-recommends \
68
- curl fontconfig \
69
- && rm -rf /var/lib/apt/lists/*
70
-
71
- WORKDIR /app
72
-
73
- # Copy built venv + patched hermes-agent from builder
74
- COPY --from=builder /app/venv /app/venv
75
- COPY --from=builder /app/hermes-agent /app/hermes-agent
76
-
77
- ENV PATH="/app/venv/bin:$PATH"
78
-
79
- # Copy Node.js runtime from builder (needed for webui-server BFF)
80
- COPY --from=builder /usr/local/bin/node /usr/local/bin/node
81
- COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
82
- # Symlink npm/npx if they don't exist
83
- RUN ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm 2>/dev/null; \
84
- ln -sf /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx 2>/dev/null; \
85
- true
86
-
87
- # Copy built web-ui from builder
88
- COPY --from=builder /app/webui-server /app/webui-server
89
- COPY --from=builder /app/webui-client /app/webui-client
90
-
91
- # Chinese fonts (download in runtime stage — only ~16MB)
92
- RUN mkdir -p /usr/share/fonts/truetype/noto && \
93
- curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Regular.otf" \
94
- -o /usr/share/fonts/truetype/noto/NotoSansSC-Regular.otf && \
95
- curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Bold.otf" \
96
- -o /usr/share/fonts/truetype/noto/NotoSansSC-Bold.otf && \
97
- fc-cache -f
98
-
99
  # Create hermes home
100
  RUN mkdir -p /root/.hermes/plugins/image_gen/pollinations
101
 
 
1
+ FROM python:3.12-slim
 
 
 
2
 
3
+ # System deps (add build tools for node-pty native compilation)
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  git curl gnupg2 fontconfig make g++ python3 \
6
  && rm -rf /var/lib/apt/lists/*
 
17
  pip install --quiet psutil networkx && \
18
  pip install --quiet -e "/app/hermes-agent[feishu,mcp,cron,pty]" 2>&1 | tail -10
19
 
20
+ # Patch: add document file extensions to auto-detection for native delivery
21
  COPY scripts/patch_file_delivery.py /tmp/patch_file_delivery.py
22
  RUN python3 /tmp/patch_file_delivery.py; rm -f /tmp/patch_file_delivery.py
23
 
24
+ # Patch: Feishu media support in send_message_tool + anti-hallucination prompts
25
  COPY patches/hermes-agent/agent/prompt_builder.py /app/hermes-agent/agent/prompt_builder.py
26
  COPY patches/hermes-agent/tools/send_message_tool.py /app/hermes-agent/tools/send_message_tool.py
27
 
28
+ # Patch: Auto-inject MEDIA: tags from write_file tool calls
29
  COPY scripts/patch_auto_media.py /tmp/patch_auto_media.py
30
  RUN python3 /tmp/patch_auto_media.py; rm -f /tmp/patch_auto_media.py
31
 
32
+ # Patch: Auto-resolve relative media paths to absolute paths
33
  COPY scripts/patch_resolve_media_paths.py /tmp/patch_resolve_media_paths.py
34
  RUN python3 /tmp/patch_resolve_media_paths.py; rm -f /tmp/patch_resolve_media_paths.py
35
 
36
+ # Install Node.js 23
37
  RUN ARCH=$(dpkg --print-architecture) \
38
  && if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; else NODE_ARCH="$ARCH"; fi \
39
+ && echo "Installing Node.js v23 for ${NODE_ARCH}" \
40
  && curl -fsSL "https://nodejs.org/dist/v23.11.0/node-v23.11.0-linux-${NODE_ARCH}.tar.gz" \
41
  -o /tmp/node.tar.gz \
42
  && tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 \
43
  && rm -f /tmp/node.tar.gz \
44
  && node --version && npm --version
45
 
46
+ # Chinese font (Noto Sans SC Regular + Bold)
47
+ RUN mkdir -p /usr/share/fonts/truetype/noto && \
48
+ curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Regular.otf" \
49
+ -o /usr/share/fonts/truetype/noto/NotoSansSC-Regular.otf && \
50
+ curl -sL "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/SC/NotoSansSC-Bold.otf" \
51
+ -o /usr/share/fonts/truetype/noto/NotoSansSC-Bold.otf && \
52
+ fc-cache -f
53
+
54
+ # Build hermes-web-ui (keep node_modules for runtime deps)
55
  RUN git clone --depth 1 https://github.com/EKKOLearnAI/hermes-web-ui.git /tmp/hermes-web-ui && \
56
  cd /tmp/hermes-web-ui && \
57
  npm install --ignore-scripts 2>&1 | tail -5 && \
 
66
  rm -rf /tmp/hermes-web-ui && \
67
  echo "hermes-web-ui build done"
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  # Create hermes home
70
  RUN mkdir -p /root/.hermes/plugins/image_gen/pollinations
71