fix(chat-ui): make docker compose stack start from a fresh clone (#4641)

* fix(chat-ui): make docker compose stack start from a fresh clone

The Chat UI stack in ruflo/docker-compose.yml could not start from a clean
checkout:

- docker-compose.yml was invalid YAML: an unquoted ": " in the required
  MONGO_INITDB_ROOT_PASSWORD message.
- The Dockerfile copies ruvocal/.env, which was never committed, and the
  build fetches /models from OPENAI_BASE_URL. Commit a secret-free .env
  pointing at the public Hugging Face router; runtime still overrides it
  through .env.local (DOTENV_LOCAL).
- mcp-bridge bound to loopback inside its container, so chat-ui could not
  reach it. Default the in-container bind to 0.0.0.0 and require
  MCP_AUTH_TOKEN, which chat-ui now sends to the bridge. The host port stays
  published on 127.0.0.1, and the bridge's own loopback default and
  fail-closed check in index.js are unchanged.
- entrypoint.sh got CRLF on Windows with core.autocrlf=true and crashed the
  container. Force LF for shell scripts through .gitattributes.

MCP_AUTH_TOKEN is now required, so existing .env files need it added.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(chat-ui): build without a committed ruvocal .env

Drop ruflo/src/ruvocal/.env (the repo does not commit .env files) and make the
Dockerfile's .env optional instead: copy it from the build context when present
(deploy builds keep supplying their own), otherwise write the same public
default, OPENAI_BASE_URL=https://router.huggingface.co/v1. A fresh clone now
builds the image without any .env. Verified the base stage with and without a
context .env.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: RuFlo <ruv@ruv.net>
Co-authored-by: r <r@x>
This commit is contained in:
authored and GitHub committed 2026-11-17 22:42:22 -05:00
1 parent dd430b045e
commit afe0f72fd3
3 files changed
+18 -6

No files matched your search

+1
View File
@@ -0,0 +1 @@
*.sh text eol=lf
+11 -5
View File
@@ -3,6 +3,9 @@
#
# Usage:
# cp .env.example .env # fill in your API keys
# # Also required in .env:
# # MONGO_INITDB_ROOT_PASSWORD=$(openssl rand -hex 32)
# # MCP_AUTH_TOKEN=$(openssl rand -hex 32)
# docker compose up -d
services:
@@ -17,7 +20,7 @@ services:
environment:
MONGO_INITDB_DATABASE: ${MONGODB_DB_NAME:-chat-db}
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:-ruflo}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:?FATAL: MONGO_INITDB_ROOT_PASSWORD is required. Generate: MONGO_INITDB_ROOT_PASSWORD=$(openssl rand -base64 32)}
MONGO_INITDB_ROOT_PASSWORD: "${MONGO_INITDB_ROOT_PASSWORD:?MONGO_INITDB_ROOT_PASSWORD is required. Generate one with: openssl rand -hex 32}"
command: ["--auth"]
# --- MCP Bridge (ruvocal version — Gemini grounded search, autopilot SSE) ---
@@ -55,8 +58,11 @@ services:
# API keys for optional groups
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
# --- ADR-166 §6 security surface ---
MCP_BIND_HOST: ${MCP_BIND_HOST:-127.0.0.1}
MCP_AUTH_TOKEN: ${MCP_AUTH_TOKEN:-}
# chat-ui reaches the bridge over the compose network, so loopback inside
# the container would be unreachable. Host exposure stays on the published
# 127.0.0.1 port above; the bridge refuses non-loopback binds without a token.
MCP_BIND_HOST: ${MCP_BIND_HOST:-0.0.0.0}
MCP_AUTH_TOKEN: "${MCP_AUTH_TOKEN:?MCP_AUTH_TOKEN is required. Generate one with: openssl rand -hex 32}"
MCP_ENABLE_TERMINAL: ${MCP_ENABLE_TERMINAL:-false}
MCP_CORS_ORIGIN: ${MCP_CORS_ORIGIN:-*}
# ADR-166 §6 Phase 2c — read-only rootfs breaks the PoC's /app/beacon.js write.
@@ -109,8 +115,8 @@ services:
ENABLE_DATA_EXPORT=true
ALLOW_IFRAME=true
OPENAI_BASE_URL=http://mcp-bridge:3001
OPENAI_API_KEY=${OPENAI_API_KEY:-sk-placeholder}
MCP_SERVERS=[{"name":"Core Tools","url":"http://mcp-bridge:3001/mcp/core"},{"name":"Intelligence & Learning","url":"http://mcp-bridge:3001/mcp/intelligence"},{"name":"Agents & Orchestration","url":"http://mcp-bridge:3001/mcp/agents"},{"name":"Memory & Knowledge","url":"http://mcp-bridge:3001/mcp/memory"},{"name":"Dev Tools & Analysis","url":"http://mcp-bridge:3001/mcp/devtools"}]
OPENAI_API_KEY=${MCP_AUTH_TOKEN}
MCP_SERVERS=[{"name":"Core Tools","url":"http://mcp-bridge:3001/mcp/core","headers":{"Authorization":"Bearer ${MCP_AUTH_TOKEN}"}},{"name":"Intelligence & Learning","url":"http://mcp-bridge:3001/mcp/intelligence","headers":{"Authorization":"Bearer ${MCP_AUTH_TOKEN}"}},{"name":"Agents & Orchestration","url":"http://mcp-bridge:3001/mcp/agents","headers":{"Authorization":"Bearer ${MCP_AUTH_TOKEN}"}},{"name":"Memory & Knowledge","url":"http://mcp-bridge:3001/mcp/memory","headers":{"Authorization":"Bearer ${MCP_AUTH_TOKEN}"}},{"name":"Dev Tools & Analysis","url":"http://mcp-bridge:3001/mcp/devtools","headers":{"Authorization":"Bearer ${MCP_AUTH_TOKEN}"}}]
COOKIE_SECURE=${COOKIE_SECURE:-false}
COOKIE_SAMESITE=${COOKIE_SAMESITE:-lax}
depends_on:
+6 -1
View File
@@ -29,7 +29,12 @@ RUN mkdir -p /home/user/.npm && chown -R 1000:1000 /home/user/.npm
USER user
COPY --chown=1000 .env /app/.env
# .env is optional in the build context: a fresh clone has none (the repo does
# not commit .env files), while deploy builds may supply one. Copy it when
# present, otherwise write the public default the chat-ui image expects.
RUN --mount=type=bind,source=.,target=/tmp/ctx \
if [ -f /tmp/ctx/.env ]; then cp /tmp/ctx/.env /app/.env; \
else printf 'OPENAI_BASE_URL=https://router.huggingface.co/v1\n' > /app/.env; fi
# Remove empty placeholder values that block .env.local overrides via dotenv-cli -c
RUN sed -i 's/^MODELS=$/# MODELS=/' /app/.env && \
sed -i 's/^TASK_MODEL=$/# TASK_MODEL=/' /app/.env