Files
miku-discord/Dockerfile.llamaswap-rocm

68 lines
1.9 KiB
Docker
Raw Normal View History

2026-01-09 00:03:59 +02:00
# Multi-stage build for llama-swap with ROCm support
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Now using official llama.cpp ROCm image (PR #18439 merged Dec 29, 2025)
2026-01-09 00:03:59 +02:00
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Stage 1: Build llama-swap UI
2026-01-09 00:03:59 +02:00
FROM node:22-alpine AS ui-builder
WORKDIR /build
# Install git
RUN apk add --no-cache git
# Clone llama-swap
RUN git clone https://github.com/mostlygeek/llama-swap.git
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Build UI (now in ui-svelte directory)
WORKDIR /build/llama-swap/ui-svelte
2026-01-09 00:03:59 +02:00
RUN npm install && npm run build
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Stage 2: Build llama-swap binary
2026-01-09 00:03:59 +02:00
FROM golang:1.23-alpine AS swap-builder
WORKDIR /build
# Install git
RUN apk add --no-cache git
# Copy llama-swap source with built UI
COPY --from=ui-builder /build/llama-swap /build/llama-swap
# Build llama-swap binary
WORKDIR /build/llama-swap
RUN GOTOOLCHAIN=auto go build -o /build/llama-swap-binary .
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Stage 3: Final runtime image using official llama.cpp ROCm image
FROM ghcr.io/ggml-org/llama.cpp:server-rocm
2026-01-09 00:03:59 +02:00
WORKDIR /app
fix: Phase 3 bug fixes - memory APIs, username visibility, web UI layout, Docker **Critical Bug Fixes:** 1. Per-user memory isolation bug - Changed CatAdapter from HTTP POST to WebSocket /ws/{user_id} - User_id now comes from URL path parameter (true per-user isolation) - Verified: Different users can't see each other's memories 2. Memory API 405 errors - Replaced non-existent Cat endpoint calls with Qdrant direct queries - get_memory_points(): Now uses POST /collections/{collection}/points/scroll - delete_memory_point(): Now uses POST /collections/{collection}/points/delete 3. Memory stats showing null counts - Reimplemented get_memory_stats() to query Qdrant directly - Now returns accurate counts: episodic: 20, declarative: 6, procedural: 4 4. Miku couldn't see usernames - Modified discord_bridge before_cat_reads_message hook - Prepends [Username says:] to every message text - LLM now knows who is texting: [Alice says:] Hello Miku! 5. Web UI Memory tab layout - Tab9 was positioned outside .tab-container div (showed to the right) - Moved tab9 HTML inside container, before closing divs - Memory tab now displays below tab buttons like other tabs **Code Changes:** bot/utils/cat_client.py: - Line 25: Logger name changed to 'llm' (available component) - get_memory_stats() (lines 256-285): Query Qdrant directly via HTTP GET - get_memory_points() (lines 275-310): Use Qdrant POST /points/scroll - delete_memory_point() (lines 350-370): Use Qdrant POST /points/delete cat-plugins/discord_bridge/discord_bridge.py: - Fixed .pop() → .get() (UserMessage is Pydantic BaseModelDict) - Added before_cat_reads_message logic to prepend [Username says:] - Message format: [Alice says:] message content Dockerfile.llamaswap-rocm: - Lines 37-44: Added conditional check for UI directory - if [ -d ui ] before npm install && npm run build - Fixes build failure when llama-swap UI dir doesn't exist bot/static/index.html: - Moved tab9 from lines 1554-1688 (outside container) - To position before container closing divs (now inside) - Memory tab button at line 673: 🧠 Memories **Testing & Verification:** ✅ Per-user isolation verified (Docker exec test) ✅ Memory stats showing real counts (curl test) ✅ Memory API working (facts/episodic loading) ✅ Web UI layout fixed (tab displays correctly) ✅ All 5 services running (llama-swap, llama-swap-amd, qdrant, cat, bot) ✅ Username prepending working (message context for LLM) **Result:** All Phase 3 critical bugs fixed and verified working.
2026-02-07 23:27:15 +02:00
# Copy llama-swap binary from builder
2026-01-09 00:03:59 +02:00
COPY --from=swap-builder /build/llama-swap-binary /app/llama-swap
# Make binaries executable
RUN chmod +x /app/llama-swap
# Add existing ubuntu user (UID 1000) to GPU access groups (using host GIDs)
# GID 187 = render group on host, GID 989 = video/kfd group on host
RUN groupadd -g 187 hostrender && \
groupadd -g 989 hostvideo && \
usermod -aG hostrender,hostvideo ubuntu && \
chown -R ubuntu:ubuntu /app
# Set environment for ROCm (RX 6800 is gfx1030)
ENV HSA_OVERRIDE_GFX_VERSION=10.3.0
ENV ROCM_PATH=/opt/rocm
ENV HIP_VISIBLE_DEVICES=0
USER ubuntu
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Override the base image's ENTRYPOINT and run llama-swap
ENTRYPOINT []
CMD ["/app/llama-swap", "-config", "/app/config.yaml", "-listen", "0.0.0.0:8080"]