test-mcp / Dockerfile
mikeboone's picture
feat(mcp): build_portal tool β€” portals inside the automated pipeline
d301844
Raw
History Blame Contribute Delete
2.07 kB
# Dockerfile β€” DemoPrep MCP Space (Hugging Face Docker Space)
#
# Runs the MCP server (mcp_server.py) over streamable-HTTP on port 7860.
# This is a SEPARATE Space from the Gradio app: same codebase, different
# entrypoint. Business logic stays in one place (demoprep_app/) β€” this Space
# just runs the MCP adapter instead of the Gradio UI.
#
# Required secrets: set in Space Settings -> Repository Secrets (see the
# mcp_server.py module docstring for the full list).
FROM python:3.11-slim
RUN useradd -m -u 1000 user
WORKDIR /app
# node + npm are required by the build_portal tool: the portal codemod is a Node
# script and the site is built with vite. Debian bookworm ships Node 18, which
# satisfies vite 5 (^18 || >=20).
RUN apt-get update && apt-get install -y git curl nodejs npm \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY --chown=user . .
# Pre-install the portal template's node_modules AS ROOT, at image build time.
# The codemod installs them on first use if absent β€” but the runtime user cannot
# write into /app, so that would fail exactly like the PromptLogger outage below.
# Installing here means every portal build finds them ready. The chown that
# follows covers this tree too.
RUN cd demoprep_app/portal/template-tse \
&& npm install --no-audit --no-fund --loglevel=error
# Runtime-writable dirs. WORKDIR creates /app owned by root, and `logs/` is
# gitignored so it is absent from the image β€” so the non-root `user` could not
# mkdir it at runtime. That is exactly what took the MCP Space down on
# 2026-08-25: PromptLogger's log_dir.mkdir() raised PermissionError: '/app/logs'
# and every build returned failed. 4b87c36 made that non-fatal; this makes
# logging actually work instead of silently degrading to memory-only.
RUN mkdir -p /app/logs/prompts /app/results /app/demo_logs \
&& chown -R user:user /app
USER user
ENV MCP_TRANSPORT=http \
MCP_HTTP_PORT=7860 \
HOME=/home/user
EXPOSE 7860
CMD ["python", "mcp_server.py"]